DB2 10.5 for Linux, UNIX, and Windows

Detecting and processing error and warning conditions in host language applications

An application program containing executable SQL statements can use either SQLCODE or SQLSTATE values to handle return codes from SQL statements.

There are two ways in which an application can get access to these values.
An SQLCODE is set by the database manager after each SQL statement executes. All database managers conform to the ISO/ANSI SQL standard, as follows:

The meaning of SQLCODE values other than 0 and 100 is product-specific.

An SQLSTATE is set by the database manager after each SQL statement executes. Application programs can check the execution of SQL statements by testing SQLSTATE instead of SQLCODE. SQLSTATE provides common codes for common error conditions. Application programs can test for specific errors or classes of errors. The coding scheme is the same for all IBM® database managers, and is based on the ISO/ANSI SQL92 standard.