[Info-ingres] OpenAPI error function called in wrong state

DATABASE

[Info-ingres] OpenAPI error function called in wrong state

Postby martin.bowes » Fri, 17 Jun 2005 22:14:46 GMT

i Everyone,

As I'm just starting the joy of using API - why?Dont ask! Lets just say
the curiosity got the better of me.

I've managed to get a connection to the database! Yay! Well at least it
claims to have connected to the database. There is no sign of a
connection being started in iircp.log....

Now I'm struggeling to get a non select query to execute. It keeps
{*filter*}ing about an API function called in the wrong state.

Anyone got any ideas?

The output from setting II_API_TRACE=5 and II_API_LOG to a suitable
file shows:

!IIapi_initAPI: initializing API.
!IIapi_initialize: INGRES API initialized, envHndl = 00000001400ED020
!IIapi_connect: connect to DBMS Server
!IIapi_connect: envHndl = 00000001400ED020, connHndl =
0000000000000000, tranHndl= 0000000000000000
!IIapi_connect: target = bowtest
!IIapi_thread(-1071947776): allocated local storage
0000000140097840
!IIapi_uiDispatch: dispatching event IIAPI_EV_CONNECT_FUNC
!Dispatch(-1071947776): SQL Conn [00000001400ED220] IDLE -->
REQ, 2 action(s)
!Dispatch(-1071947776): action[1] REMC
!Dispatch(-1071947776): action[2] CONN
!IIapi_query: starting a query
!IIapi_query: connHndl = 00000001400ED220, tranHndl =
0000000000000000, queryType = 0
!IIapi_query: queryText = drop table next_id
!IIapi_uiDispatch: dispatching event IIAPI_EV_QUERY_FUNC
!SQL Conn Evaluate: API function called in wrong state
!Dispatch(-1071947776): SQL Conn [00000001400ED220] REQ -->
REQ, 1 action(s)
!Dispatch(-1071947776): action[1] CBIF
!IIapi_appCallback: request completed, status = FAILURE
!IIapi_getErrorInfo: retrieving errors from API
!IIapi_getErrorInfo: handle = 00000001400ED220

Martin Bowes
--
Random Titus Quote #0:
Be normal and the crowd will accept you.
Be deranged, and they'll make you their leader.


<?xml version="1.0" ?><html>
<head>
<title></title>
</head>
<body>
<div align="left"><font face="Arial"><span style="font-size:10pt">Hi Everyone,</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">As I'm just starting the joy of using API - why?Dont ask! Lets just say
the curiosity got the better of me.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I've managed to get a connection to the database! Yay! Well at least it
claims to have connected to the database. There is no sign of a
connection being started in iircp.log....</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Now I'm struggeling to get a non select query to execute. It keeps
{*filter*}ing about an API function called in the wrong state.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Anyone got any ideas?</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">The output from setting II_API_TRACE=5 and II_API_LOG to a suitable
file shows:</span></font></div>
<div align="le

RE: [Info-ingres] OpenAPI error function called in wrong state

Postby Croker, Grant » Sat, 18 Jun 2005 00:09:02 GMT

Martin,

From the trace it looks like you are not calling IIapi_wait() to wait
for the last API call (IIapi_connect()) to complete. The following code
should do the trick:

	IIAPI_GENPARM *genParm;

	static IIAPI_WAITPARM waitParm = {
		-1,		/* no timeout, we don't want
asynchronous queries */
		0		/* wt_status (output) */
	};

	while (genParm->gp_completed == FALSE) {
		IIapi_wait(&waitParm);
	}

HTH

grant

________________________________________
From:  XXXX@XXXXX.COM 
[mailto: XXXX@XXXXX.COM ] On Behalf Of
 XXXX@XXXXX.COM 
Sent: Thursday, June 16, 2005 3:15 PM
To:  XXXX@XXXXX.COM 
Subject: [Info-ingres] OpenAPI error function called in wrong state

Hi Everyone,

As I'm just starting the joy of using API - why?Dont ask! Lets just say
the curiosity got the better of me.

I've managed to get a connection to the database! Yay! Well at least it
claims to have connected to the database. There is no sign of a
connection being started in iircp.log....

Now I'm struggeling to get a non select query to execute. It keeps
{*filter*}ing about an API function called in the wrong state.

Anyone got any ideas?

The output from setting II_API_TRACE=5 and II_API_LOG to a suitable file
shows:

!IIapi_initAPI: initializing API.
!IIapi_initialize: INGRES API initialized, envHndl = 00000001400ED020
!IIapi_connect: connect to DBMS Server
!IIapi_connect: envHndl = 00000001400ED020, connHndl = 0000000000000000,
tranHndl= 0000000000000000
!IIapi_connect: target = bowtest
!IIapi_thread(-1071947776): allocated local storage 0000000140097840
!IIapi_uiDispatch: dispatching event IIAPI_EV_CONNECT_FUNC
!Dispatch(-1071947776): SQL Conn [00000001400ED220] IDLE --> REQ, 2
action(s)
!Dispatch(-1071947776): action[1] REMC
!Dispatch(-1071947776): action[2] CONN
!IIapi_query: starting a query
!IIapi_query: connHndl = 00000001400ED220, tranHndl = 0000000000000000,
queryType = 0
!IIapi_query: queryText = drop table next_id
!IIapi_uiDispatch: dispatching event IIAPI_EV_QUERY_FUNC
!SQL Conn Evaluate: API function called in wrong state
!Dispatch(-1071947776): SQL Conn [00000001400ED220] REQ --> REQ, 1
action(s)
!Dispatch(-1071947776): action[1] CBIF
!IIapi_appCallback: request completed, status = FAILURE
!IIapi_getErrorInfo: retrieving errors from API
!IIapi_getErrorInfo: handle = 00000001400ED220

Martin Bowes
Random Titus Quote #0:
Be normal and the crowd will accept you.
Be deranged, and they'll make you their leader.



RE: [Info-ingres] OpenAPI error function called in wrong state

Postby martin.bowes » Sat, 18 Jun 2005 20:56:01 GMT

Hi Grant,

	Spot on with the IIapi_wait you API Guru you!

	And now that I've worked out that the manual was really 
serious about that IIapi_close business as well, I can actually commit 
the transaction!

	Sweet!

	Now onto stage 2 ..... Cue evil laughter.

	Marty
Random Duckman Quote #66:
Cornfed: Look, there's a tufted titmouse.
Duckman: Really? A big titmouse?
Cornfed: A really big titmouse?
Duckman: Man, just look at the size of that titmouse?
Cornfed: That is one humongous titmouse.
Duckman: You think I can I grab the titmouse?
Cornfed: Sure, its fun to grab the titmouse.
Duckman: When's the V-chip coming?
Cornfed: Not for another six months.



Similar Threads:

1.[Info-ingres] OpenAPI Calling a database procedure

Hi.

If you are executing a procedure without params then sd_descriptorCount
should be 1. This could be the cause of the hang? The code below is what
I do within the PHP extension to support procedures without params. I
have tagged on the end the code for getting the return code from a
procedure. 

	queryParm.qy_genParm.gp_callback = NULL;
	queryParm.qy_genParm.gp_closure = NULL;
	queryParm.qy_connHandle = connHandle;
	queryParm.qy_tranHandle = tranHandle;
	queryParm.qy_stmtHandle = NULL;
	queryParm.qy_queryType  = IIAPI_QT_EXEC_PROCEDURE;
	queryParm.qy_parameters = TRUE;
	queryParm.qy_queryText  = NULL;

	IIapi_query(&queryParm);

	while( queryParm.qy_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	if (waitParm.wt_status != IIAPI_ST_SUCCESS)
	{
        ... handle error ...
	}

	DescrBuffer = (IIAPI_DESCRIPTOR
*)ecalloc(sizeof(IIAPI_DESCRIPTOR),1);
	setDescrParm.sd_genParm.gp_callback = NULL;
	setDescrParm.sd_genParm.gp_closure = NULL;
setDescrParm.sd_stmtHandle = stmtHandle;
	setDescrParm.sd_descriptorCount = 1; /* 	no params just
the name 
								of the
procedure */
	setDescrParm.sd_descriptor = DescrBuffer;

	setDescrParm.sd_descriptor[0].ds_dataType = IIAPI_CHA_TYPE;
	setDescrParm.sd_descriptor[0].ds_length = strlen(procname);
	setDescrParm.sd_descriptor[0].ds_nullable = FALSE;
	setDescrParm.sd_descriptor[0].ds_precision = 0;
	setDescrParm.sd_descriptor[0].ds_scale = 0;
	setDescrParm.sd_descriptor[0].ds_columnType = IIAPI_COL_SVCPARM;
	setDescrParm.sd_descriptor[0].ds_columnName = NULL;

      IIapi_setDescriptor( &setDescrParm );

	while( setDescrParm.sd_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	if (waitParm.wt_status != IIAPI_ST_SUCCESS)
	{
        ... handle error ...
	}

	DataBuffer = (IIAPI_DATAVALUE
*)calloc(sizeof(IIAPI_DATAVALUE),1);
	putParmParm.pp_genParm.gp_callback = NULL;
	putParmParm.pp_genParm.gp_closure = NULL;
	putParmParm.pp_stmtHandle = stmtHandle;
	putParmParm.pp_parmCount = setDescrParm.sd_descriptorCount;
	putParmParm.pp_parmData =  DataBuffer;
	putParmParm.pp_moreSegments = 0;

	putParmParm.pp_parmData[0].dv_null = FALSE;
	putParmParm.pp_parmData[0].dv_length = strlen(procname );
    	putParmParm.pp_parmData[0].dv_value = procname;
	IIapi_putParms( &putParmParm );

	while( putParmParm.pp_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	if (waitParm.wt_status != IIAPI_ST_SUCCESS)
	{
        ... handle error ...
	}

	getDescrParm.gd_genParm.gp_callback = NULL;
	getDescrParm.gd_genParm.gp_closure  = NULL;
	getDescrParm.gd_stmtHandle = stmtHandle;

	IIapi_getDescriptor(&getDescrParm);

	while( getDescrParm.gd_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	if (waitParm.wt_status != IIAPI_ST_SUCCESS)
	{
        ... handle error ...
	}
	getQInfoParm.gq_genParm.gp_callback = NULL;
	getQInfoParm.gq_genParm.gp_closure = NULL;
	getQInfoParm.gq_stmtHandle = queryParm.qy_stmtHandle;

	IIapi_getQueryInfo( &getQInfoParm );

	while( getQInfoParm.gq_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	if (waitParm.wt_status != IIAPI_ST_SUCCESS)
	{
        ... handle error ...
	}

	if ( getQInfoParm.gq_mask & IIAPI_GQ_PROCEDURE_RET )
	{
        /* we have a return value */

		returnvalue = getQInfoParm.gq_procedureReturn;

	}

Note if you want to return rows via a procedure a call to
IIapi_getQueryInfo() will destroy the row data being returned. I believe
the same is true for returning byref values in a procedure. I have not
worked out how to deal with this yet other than documenting it in big
neon letters.



> -----Original Message-----
> From:  XXXX@XXXXX.COM  [mailto: XXXX@XXXXX.COM ]
> Sent: Wednesday, July 13, 2005 2:53 PM
> Subject: OpenAPI Caling a database procedure
> 
> Hi Grant et al,
>
> I'm trying call a database procedure synchronously from an OpenAPI
> application. The procedure has no parameters, all I want is the return
> value. My understanding is that I set IIapi_query to say I'm executing
a
> database procedure. It will not do anything until the necessary
> parameters (including procedure name and owner) are supplied and
> filled in.
> 
> However, the code seems to hang at the initial iiapi_query() call.
> 
> I am using in order the following:
> IIapi_query()
> 	QueryParm.qy_queryType=IIAPI_QT_EXEC_PROCEDURE;
> 	QueryParm.qy_queryText=NULL;
> 	QueryParm.qy_parameters=TRUE;
>     I don't wait on gp_completed.
> 
> IIapi_setDescriptor()
> 	setDescParm.sd_stmtHandle=QueryParm.qy_stmtHandle;
> 	setDescParm.sd_descriptorCount=2;
> 
>     I then allocate storage for two parameter descriptors for the
>     array setDescParm.sd_descriptor. In each element of which I
>     set ds_dataType = IIAPI_CHA_TYPE,
>     ds_nullable = FALSE,
>     ds_columnType = IIAPI_COL_SVCPARM
>     ds_columnName = NULL
> 
>     I wait on gp_completed.
> 
> IIapi_putParms()
> 	Fill in the procedure name, owner values described above, call
> the procedure an wait on gp_completed.
> 
> At this point I wait on the IIapi_query to complete.
> Then I call IIapi_get_QueryInfo to pick up the procedure return value.
> 
> Martin Bowes
> --
> Random Farscape Quote #26:
> John     - I think we have to put Grandma in a home.
> Ka'Dargo - We could burn her.
> John     - You burn your old people!
> Ka'Dargo - No, but in her case...
> 
> 


2."Query cannot be closed in the current state"- A strange run time error while using OPENapi

Hello Everybody

My application uses OPENapi interface to interact with OpenIngres.

First it does some internal settings and connects, involving following
calls:

IIapi_initialize: initParm=FCB85250
IIapi_connect: connectParm=FCB93B58
.
.
and some

IIapi_query: query=FCB7FF0C
IIapi_setDescriptor: setDescrParm=FCB7FF0C
IIapi_putParms: putParmParm=FCB7FF0C
IIapi_getDescriptor: getDescrParm=FCB7FF0C
IIapi_wait: waitParm=FCB7FF0C
.
.
Followed by some:

IIapi_getColumns: getColParm=FCB7FF0C
IIapi_wait: waitParm=FCB7FF0C
IIapi_close: closeParm=FCB7FF0C
.
.
Now it attempts to do a simple query: SELECT * FROM
INGRES.HS_TRANSACTION_LOG

IIapi_query: query=FCB7FF0C
IIapi_getDescriptor: getDescrParm=FCB7FF0C
IIapi_wait: waitParm=FCB7FF0C
IIapi_close: closeParm=FCB7FF0C
IIapi_getErrorInfo: getEInfoParm=5D2898
.
.
and fails due to the following error:

XXXXXX>> : ERROR '5000R' 13172743: Query cannot be closed in the current
state, it may only be cancelled.


Does anybody have any idea what is this message and where does it come from?

Thanx + Regards

Hillel.


3.[Info-Ingres] floor() and ceil()...wrong, wrong, wrong!

4.[Info-ingres] RES: [Info-ingres] Wrong results returned from outer join

5.[Info-ingres] OpenAPI Caling a database procedure

Hi Grant et al,

I'm trying call a database procedure synchronously from an OpenAPI 
application. The procedure has no parameters, all I want is the return 
value. My understanding is that I set IIapi_query to say I'm executing a 
database procedure. It will not do anything until the necessary 
parameters (including procedure name and owner) are supplied and 
filled in.

However, the code seems to hang at the initial iiapi_query() call. 

I am using in order the following:
IIapi_query()
	QueryParm.qy_queryType=IIAPI_QT_EXEC_PROCEDURE;
	QueryParm.qy_queryText=NULL;
	QueryParm.qy_parameters=TRUE; 
    I don't wait on gp_completed.

IIapi_setDescriptor()
	setDescParm.sd_stmtHandle=QueryParm.qy_stmtHandle;
	setDescParm.sd_descriptorCount=2;

    I then allocate storage for two parameter descriptors for the 
    array setDescParm.sd_descriptor. In each element of which I 
    set ds_dataType = IIAPI_CHA_TYPE,
    ds_nullable = FALSE, 
    ds_columnType = IIAPI_COL_SVCPARM
    ds_columnName = NULL

    I wait on gp_completed.

IIapi_putParms()
	Fill in the procedure name, owner values described above, call 
the procedure an wait on gp_completed.

At this point I wait on the IIapi_query to complete.
Then I call IIapi_get_QueryInfo to pick up the procedure return value.

Martin Bowes
Random Farscape Quote #26:
John     - I think we have to put Grandma in a home.
Ka'Dargo - We could burn her.
John     - You burn your old people!
Ka'Dargo - No, but in her case...

6. [Info-ingres] OpenAPI Weirdness

7. [Info-ingres] OpenAPI Status Codes

8. [Info-ingres] OpenAPI Parameter Place Holders



Return to DATABASE

 

Who is online

Users browsing this forum: No registered users and 40 guest