SQL Return Codes are used on a day-to-day basis for the diagnosis of programming failures as a result of SQL calls by DB2 computer programs. An important feature of DB2 programs is the error processing. The error diagnostic containing the SQL Return Code is held in the field SQLCODE within the DB2 SQLCA block.
SQLCODE is no longer part of the SQL-standard. The SQL-standard replaced SQLCODE by the more detailed SQLSTATE.
Video DB2 SQL return codes
SQLCA
The SQL communications area (SQLCA) structure is used within the DB2 program to return a feedback to the application program. The information in the SQLCA and the SQLCODE field are updated after every API call with a SQL statement. SQLCA contains ERROR HANDLING data.
Maps DB2 SQL return codes
SQLCODE
The SQLCODE field contains the SQL return code. The code can be zero (0), negative or positive:
- 0 means that the execution was successful.
- Negative values incidate an unsuccessful execution with an error.
An example is -911, which means that a timeout has occurred with a rollback. - Positive value mean a successful execution with a warning.
An example is +100, which means that no matching rows were found or that the cursor has reached the end of the table.
Here is a more comprehensive list of the SQLCODEs for DB2. Note that this list is not exhaustive. Also note that some SQLCODEs may only occur in specific DB2 products; e.g., only on DB2 z/OS, only on DB2 LUW, or only on DB2 iSeries (AS400).
Zero (Successful)
0 Successful
Negative values (Errors)
Positive Values (Warnings)
References
- "DB2 Version 9.1 for z/OS Codes" (PDF). September 2013.
- "DB2 SQL CODE Description and solutions".
- "SQL codes". September 2013.
Source of the article : Wikipedia