DB2 SQLCODEs – Complete Guide for Mainframe
Developers
This document contains the most important DB2 SQLCODEs used by Mainframe Developers in
real-time projects and interviews. Each SQLCODE is explained with meaning and usage.
1. Successful & Warning SQLCODEs
• SQLCODE = 0 : Successful execution of SQL statement
• SQLCODE = +100 : No rows found (very common with SELECT INTO and cursor fetch)
• SQLCODE = +304 : Data truncation warning
• SQLCODE = +802 : Arithmetic overflow or underflow
2. NULL & Data Related SQLCODEs
• SQLCODE = -305 : NULL fetched into non-nullable host variable
• SQLCODE = -407 : NULL value not allowed in column
• SQLCODE = -311 : Length mismatch in host variable
3. Constraint Related SQLCODEs
• SQLCODE = -803 : Duplicate key / unique constraint violation
• SQLCODE = -530 : Foreign key violation (parent row not found)
• SQLCODE = -531 : Delete restricted due to foreign key dependency
4. Cursor Related SQLCODEs
• SQLCODE = -501 : Cursor not open
• SQLCODE = -502 : Cursor already open
• SQLCODE = -504 : Cursor not defined
• SQLCODE = +100 : End of cursor (no more rows)
5. Object & Syntax Errors
• SQLCODE = -204 : Object (table/view) not found
• SQLCODE = -205 : Object exists in another schema
• SQLCODE = -206 : Column not found
• SQLCODE = -104 : SQL syntax error
6. Authorization & Security
• SQLCODE = -551 : Authorization failure (no permission)
7. Resource & Environment Issues
• SQLCODE = -904 : Resource unavailable (tablespace stopped)
• SQLCODE = -911 : Deadlock or timeout (rollback performed)
• SQLCODE = -913 : Deadlock or timeout (no rollback)
• SQLCODE = -923 : DB2 resource limit exceeded
8. Program & Bind Issues
• SQLCODE = -805 : DBRM or package not found
• SQLCODE = -818 : Timestamp mismatch (rebind required)
• SQLCODE = -30081 : DB2 connection failure
Top Interview SQLCODEs to Remember: 0, +100, -305, -803, -904, -911, -805, -818, -204