8. SQL Statements : INQUIRE_SQL : Description
 
Share this page                  
Description
The INQUIRE_SQL statement enables an embedded SQL program to retrieve a variety of runtime information, such as:
Information about the last executed database statement
The message number and text from a message statement executed by a database procedure
Status information, such as the current session ID, the type of error (local or generic) being returned to the application, and whether a transaction is currently open
Information about the last event removed from the event queue
The value of the last single logical key inserted into the database by the application
Provides an application program with a variety of runtime information.
INQUIRE_SQL is a synonym for INQUIRE_INGRES.
The INQUIRE_SQL statement does not execute queries; the information INQUIRE_SQL returns to the program reflects the results of the last query that was executed. For this reason, the INQUIRE_SQL statement must be issued after the database statement about which information is desired, and before another database statement is executed (and resets the values returned by INQUIRE_SQL).
To retrieve error or message information about database procedure statements, issue the INQUIRE_SQL statement inside an error or message handler called by the WHENEVER SQLERROR or WHENEVER SQLMESSAGE statement.
Some of the information returned by INQUIRE_SQL is also available in the SQLCA. For example, the error number returned by the object errorno is also available in the SQLCA sqlcode field.
Similarly, when an error occurs, the error text can be retrieved using INQUIRE_SQL with the ERRORTEXT object or it can be retrieved from the SQLCA sqlerrm variable. ERRORTEXT provides the complete text of the error message, which is often truncated in sqlerrm.
This statement must be terminated according to the rules of your host language.