SQLCODE
The SQLCODE is also set by Db2 after each SQL statement is executed.
SQLCODE
The SQLCODE value is set by Db2 after each statement is executed, as shown in the following table.
SQLCODE value | Meaning | SQLCODE descriptions |
---|---|---|
SQLCODE = 0 | Successful execution, if SQLWARN0 is blank. If SQLWARN0 = 'W', successful execution with warning. |
000 |
SQLCODE = 100 | No data was found. For example, a FETCH statement returned no data because the cursor was positioned after the last row of the result table. | +100 |
SQLCODE > 0 and not = 100 | Successful execution with a warning. | +sqlcode-num |
SQLCODE < 0 | Execution was not successful. | -sqlcode-num |
For PDF format descriptions of the SQL codes that Db2 13 might issue, see Codes.
In the case of a LOOP statement, the SQLSTATE is set after the END LOOP portion of the LOOP statement completes. With the REPEAT statement, the SQLSTATE is set after the UNTIL and END REPEAT portions of the REPEAT statement completes.
The SQL standard does not define the meaning of any other specific positive or negative values of SQLCODE, and the meaning of these values is not the same in all implementations of SQL.
If the application is using Db2 ODBC, an SQLCODE is only returned if the application issues the SQLGetSQLCA function.