Re: Getting the last query when an error occured
Posted in 2003
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: > 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