DB2 Error codes

Error code can be handled in the program by using SQLCODE validation after each query executed. Most of very frequent error codes described below. The SQLCODE is equal to 000, the query executed successfully. If the SQLCODE is positive, Then the Query executed with Warning. If the SQLCODE is negative, then the Query returns errors.

+100End of the ROWS fetched in cursorRows not found in the table to select which satisfies the condition.Rows not found in the table to UPDATE/DELETE in the table which satisfies the condition.
-180Date format error (MM:DD:YYYY) – i.e. the Date using for the Move/to compare is different from target date format.Date was not moved to the target field which is required to.
-181Date internal values (MM>12, DD>31)Date and Month values are exceeds its maximum.
-305Null values exception.The cursor fetches returning the null values which was not handled with NULL indicator.The SELECT query retrieving NULL values which are not handled with NULL indicator.The UPDATE/INSERT trying to insert/update NULL values without handling it through NULL indicator.
-310Missing decimal values.This will happen when any Numeric host variable is used to update the column which is having the decimal equalent column.
-313Mismatch between number of host variables & number of columns selected. Mismatch between the number of host variables & numbers of columns selected in SELECT query or FETCH cursor.
-502Cursor not opened.The program tries to fetch the data for a particular cursor which is not opened.
-503Cursor already opened.The program tries to open the cursor which is already opened.
-532Foreign key violation.
-803Duplicate records.Program tries to insert the rows which s already existed with the same key.Program tries to update the existing row which is equalent to the key that is already existed in the table.
-805Plan not found / resource not available.Program tries to call the program which the plan got corrupted or the plan got deleted.
-811cursor not defined/select trying to retrieve multiple records.Normal select statement in the program retrieving more than one row from the table which needs a cursor declaration.
-818Timestamp mismatches error.As we discussed in the BIND process, if the timestamp mismatched during the compilation, the above error will be thrown when calling the particular modules which didn’t binded properly.
-904Resource not available.
-911DEAD LOCK with timeout.
-913DEAD LOCK with roll back.
-922Authorization failure.
Note! + SQLCODE ------ will return the SQL return code for the query provided but not for the condition provided.All 900 series SQLCODE are Authorization and DEADLOCK errors.