dbTalk Databases Forums  

Getting the last query when an error occured

comp.databases.informix comp.databases.informix


Discuss Getting the last query when an error occured in the comp.databases.informix forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
hobbes
 
Posts: n/a

Default Getting the last query when an error occured - 08-08-2003 , 02:17 AM






HI !

Well, another one !


Yes, once again a little question for the newsgroup !

So i begin my explanation :
with ESQL/C
As all my "C" program are services, i would like to log error to "maybe"
interact with it .
But what i'm trying to obtain unsuccessfully for some day now, is to get the
text of the last query that generates an error !


eg: in the code there is an
exec sql select a,b from alpha;

then I check the result of the command.
(b is not in the table)
so => error i got the message : "Error : Column(b) not foun in any table in
the query"

but since our whole code is pretty huge, it would be great to have the query
that make the error : "select a,b from alpha"

so we can pretty easely diagnose what the error is exactly and the gravity
of it.
In that case it's just the name of the column we can say it would take 5mn
of correction , 5 mn of compilation, and 5-10 mn of test(if we're nor
sure... ).


we're doing this with all the database we work with.
So i think that i just missing the thing and that Informix have structure
for this....
(but i can't find information about this ... i try but i can't ...)


Thank you by advance for any answers !

Arnaud



Reply With Quote
  #2  
Old   
preetinder dhaliwal
 
Posts: n/a

Default Re: Getting the last query when an error occured - 08-08-2003 , 05:34 PM







Well, there is one messy way-

put in an error handler in ur ec program on sqlerror

in error handler getpid from getpid c call. now query on syssessions to get ur
sessionid and with this session id, get the dump of syssqlstat. this will give
ur last sql statement , provided ur database connection has not been lost.




Rgds
Preetinder

hobbes wrote:

Quote:
HI !

Well, another one !

Yes, once again a little question for the newsgroup !

So i begin my explanation :
with ESQL/C
As all my "C" program are services, i would like to log error to "maybe"
interact with it .
But what i'm trying to obtain unsuccessfully for some day now, is to get the
text of the last query that generates an error !

eg: in the code there is an
exec sql select a,b from alpha;

then I check the result of the command.
(b is not in the table)
so => error i got the message : "Error : Column(b) not foun in any table in
the query"

but since our whole code is pretty huge, it would be great to have the query
that make the error : "select a,b from alpha"

so we can pretty easely diagnose what the error is exactly and the gravity
of it.
In that case it's just the name of the column we can say it would take 5mn
of correction , 5 mn of compilation, and 5-10 mn of test(if we're nor
sure... ).

we're doing this with all the database we work with.
So i think that i just missing the thing and that Informix have structure
for this....
(but i can't find information about this ... i try but i can't ...)

Thank you by advance for any answers !

Arnaud
sending to informix-list


Reply With Quote
  #3  
Old   
preetinder dhaliwal
 
Posts: n/a

Default Re: Getting the last query when an error occured - 08-08-2003 , 05:56 PM




sorry,

there is one problem with this, as soon as you run another query ( like select
* from syssqlstat), the sql statement in table changes, so , you can write a
standalone server which u can call in error handler and it will return you the sql
statement

preetinder dhaliwal wrote:

Quote:
Well, there is one messy way-

put in an error handler in ur ec program on sqlerror

in error handler getpid from getpid c call. now query on syssessions to get ur
sessionid and with this session id, get the dump of syssqlstat. this will give
ur last sql statement , provided ur database connection has not been lost.

Rgds
Preetinder

hobbes wrote:

HI !

Well, another one !

Yes, once again a little question for the newsgroup !

So i begin my explanation :
with ESQL/C
As all my "C" program are services, i would like to log error to "maybe"
interact with it .
But what i'm trying to obtain unsuccessfully for some day now, is to get the
text of the last query that generates an error !

eg: in the code there is an
exec sql select a,b from alpha;

then I check the result of the command.
(b is not in the table)
so => error i got the message : "Error : Column(b) not foun in any table in
the query"

but since our whole code is pretty huge, it would be great to have the query
that make the error : "select a,b from alpha"

so we can pretty easely diagnose what the error is exactly and the gravity
of it.
In that case it's just the name of the column we can say it would take 5mn
of correction , 5 mn of compilation, and 5-10 mn of test(if we're nor
sure... ).

we're doing this with all the database we work with.
So i think that i just missing the thing and that Informix have structure
for this....
(but i can't find information about this ... i try but i can't ...)

Thank you by advance for any answers !

Arnaud
sending to informix-list


Reply With Quote
  #4  
Old   
Umberto Quaia
 
Posts: n/a

Default Re: Getting the last query when an error occured - 08-29-2003 , 06:05 AM




"hobbes" <pasdespam (AT) yahoo (DOT) fr> wrote
Quote:
with ESQL/C
As all my "C" program are services, i would like to log error to
"maybe"
interact with it .
But what i'm trying to obtain unsuccessfully for some day now, is to
get the
text of the last query that generates an error !

eg: in the code there is an
exec sql select a,b from alpha;

then I check the result of the command.
(b is not in the table)
so => error i got the message : "Error : Column(b) not foun in any
table in
the query"

but since our whole code is pretty huge, it would be great to have
the query
that make the error : "select a,b from alpha"

so we can pretty easely diagnose what the error is exactly and the
gravity
of it.
In that case it's just the name of the column we can say it would
take 5mn
of correction , 5 mn of compilation, and 5-10 mn of test(if we're
nor
sure... ).

we're doing this with all the database we work with.
So i think that i just missing the thing and that Informix have
structure
for this....
(but i can't find information about this ... i try but i can't ...)
I don't know if/how that may be done via ESQL/C,
but if you have DBA access, you may try with:
1) stop program with the connection still open
2) onstat -g ses to identify the session
3) onstat -g sql <session-id> to look at last SQL code
(hoping there is enough room for everything... ;-) )

Umberto




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.