DB2 UDB CLI SQLSTATE values

 

Because different database servers often have different diagnostic message codes, DB2® UDB call level interface (CLI) provides a standard set of SQLSTATE values that are defined by the X/Open SQL CAE specification. This allows consistent message handling across different database servers. SQLSTATE values are alphanumeric strings of 5 characters (bytes) with a format of ccsss, where cc indicates class and sss indicates subclass. Any SQLSTATE that has a class of:

The SQLError() function also returns an error code if the code is generated by the system. When the application is connected to an IBM® database server, the error code is SQLCODE. If the code is generated by DB2 UDB CLI instead of on the system, the error code is set to -99999.

DB2 UDB CLI SQLSTATE values include both additional IBM-defined SQLSTATE values that are returned by the database server, and DB2 UDB CLI-defined SQLSTATE values for conditions that are not defined in the X/Open specification. This allows for the maximum amount of diagnostic information to be returned. When applications are run in Windows® using ODBC, it is also possible to receive ODBC-defined SQLSTATE values. Follow these guidelines for using SQLSTATE values within your application:

 

Parent topic:

Diagnostics in a DB2 UDB CLI application