SQL codes

When IMS runs an SQL statement, it returns information about the statement execution. This information includes the SQL return code (SQLIMSCODE) and the SQL state (SQLIMSSTATE), which indicate whether statement execution was successful.

Application programs that contain executable SQL statements must provide one of the following elements:

  • Provide a structure named SQLIMSCA using the INCLUDE SQLIMSCQ statement. The SQLIMSCA includes the SQLIMSCODE and SQLSTATE, SQLIMSERRMC in addition to other status information. You can provide an SQLIMSCA by using the INCLUDE SQLIMSCA statement.

For the complete contents of the SQLIMSCA, see SQL communication area (SQLIMSCA).

For information on how to use an SQLIMSCA in your application programs, see Checking the execution of SQL statements by using the SQLIMSCA.

SQLIMSCODE

SQLIMSCODE is set by IMS after each SQL statement is run.

SQLIMSCODE = 0
Execution was successful.
SQLIMSCODE > 0
Execution was successful with a warning.
SQLIMSCODE < 0
Execution was not successful.
SQLIMSCODE = 100
No data was found. For example, a FETCH statement returned no data because the cursor was positioned after the last row of the result table.

SQLIMSSTATE

SQLIMSSTATE is also set by IMS after the execution of each SQL statement. SQLIMSSTATE is a 5-byte character string variable in the SQLIMSCA.

SQLIMSSTATE provides application programs with common codes for common error conditions (the values of SQLIMSSTATE are product-specific only if the error or warning is product-specific). Furthermore, SQLIMSSTATE is designed so that application programs can test for specific errors or classes of errors. The coding scheme is the same for all IBM® relational database products.

SQLIMSERRMC

SQLIMSERRMC is also set by IMS after the execution of each SQL statement. It contains a message text that describes the error.