SQL Return Codes are used on a day-to-day basis for the diagnosis of programming failures as a result of
SQL calls by
IBM Db2
Db2 is a family of data management products, including database servers, developed by IBM. It initially supported the relational model, but was extended to support object–relational features and non-relational structures like JSON a ...
programs. An important feature of
IBM Db2
Db2 is a family of data management products, including database servers, developed by IBM. It initially supported the relational model, but was extended to support object–relational features and non-relational structures like JSON a ...
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.
SQLCA
The SQL communications area (SQLCA) structure is used within the
IBM Db2
Db2 is a family of data management products, including database servers, developed by IBM. It initially supported the relational model, but was extended to support object–relational features and non-relational structures like JSON a ...
program to return feedback to the
application program.
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 indicate 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 for
IBM i
IBM i (the ''i'' standing for ''integrated'') is an operating system developed by IBM for IBM Power Systems. It was originally released in 1988 as OS/400, as the sole operating system of the IBM AS/400 line of systems. It was renamed to i5/OS in ...
.
Zero (Successful)
0 Successful
Negative values (Errors)
Positive Values (Warnings)
References
*
*
*
{{DEFAULTSORT:Db2 Sql Return Codes
Articles copied to Wikibooks in need of cleanup
IBM DB2