Informix – Get last executed SQL query

This content 8 years old. Please, read this page keeping its age in mind along with the fact technology changes fast and the information on this page me be outdated, not best practice, or plain wrong.

This is my preferred method.

onstat -g ses <sesid>

Where <sesid> is the session id of the connected user querying the database.

To get the session id

onstat -g ses

This will produce output similar to below.

IBM Informix Dynamic Server Version 9.40.FC7     -- On-Line -- Up 4 days 09:44:52 -- 1445712 Kbytes

session                                      #RSAM    total      used       dynamic
id       user     tty      pid      hostname threads  memory     memory     explain
31457    informix -        0        -        0        12288      11368      off
31450    informix -        0        -        0        12288      11368      off

That will print out all the sessions;  from there, use the session id column (column 1) to get the session id and plug it into the first command to show last executed statement.

onstat -g ses 31457

This produced the following output for me

Sess  SQL            Current            Iso Lock       SQL  ISAM F.E.
Id    Stmt type      Database           Lvl Mode       ERR  ERR  Vers Explain
30943 -              v004               CR  Not Wait   0    0    9.03 Off

Last parsed SQL statement :
  select distinct(tmptype) from form_cat

Speak Your Mind


This site uses Akismet to reduce spam. Learn how your comment data is processed.