informixembedded-sqldbaccess

How to get previous executed sql in informix


On my esql program when an sql fails and generates the exception I want to print the SQL that generated the exception. For that I need to find out how to get the previously executed SQL. I am running informix 11.5. I tried the following but nothing works

select * from sysmaster:sysconblock where cbl_sessionid in (select dbinfo('SessionId') from sysmaster:syssqlstat);

SELECT scs_sqlstatement FROM sysmaster:syssqlcurses WHERE scs_sessionid in (select dbinfo('SessionId') from sysmaster:syssqlstat);

All these get the sql of it self. For example if I run select * from sysmaster:sysconblock it show "select * from sysmaster:sysconblock" in the last executed. Is there any way to get this in informix? and is it [possible to do it on ESQL program?

Many Thanks


Solution

  • Couldn't do it on the EQSL but able to do it on the server and find out the offending SQL

    Select sysadmin database

    dbaccess sysadmin
    

    run the following statement

    EXECUTE FUNCTION task("set sql tracing on", 100, "10k","high","global");
    

    On the commandline

    onstat -g his