SQL return codes

The GET DIAGNOSTICS statement can be used in all languages to return return codes and other information about the previous SQL statement. For more information, see GET DIAGNOSTICS.

Additionally, each host language provides a mechanism for handling SQL return codes:

SQLSTATE

Regardless of whether the application program provides an SQLCA or a stand-alone variable, SQLSTATE is also set by the database manager after execution of each SQL statement. Thus, application programs can check the execution of SQL statements by testing SQLSTATE instead of SQLCODE.

SQLSTATE provides application programs with common codes for common error conditions. Furthermore, SQLSTATE is designed so that application programs can test for specific errors or classes of errors. The scheme is the same for all database managers and is based on the ISO/ANSI SQL 2003 Core standard. A complete list of SQLSTATE classes and SQLSTATEs associated with each SQLCODE is supplied in the SQL Messages and Codes book in the iSeries Information Center.

SQLCODE

The SQLCODE is also set by the database manager after each SQL statement is executed as follows:

A complete listing of DB2 UDB for iSeries SQLCODEs and their corresponding SQLSTATEs is provided in the SQL Messages and Codes book in the iSeries Information Center.



[ Top of Page | Previous Page | Next Page | Contents | Index ]