Sei sulla pagina 1di 4

DB2 SQL return codes

DB2 SQL return codes


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.

SQLCA
The SQL communications area (SQLCA) structure is used within the DB2 program to return error information to the application program. This information in the SQLCA and the SQLCODE field is updated after every API call for the SQL statement...

SQLCODE
The SQLCODE field contains the SQL return code. The code can be zero (0), negative or positive. 0 means successful execution. Negative means unsuccessful with an error. An example is -911 which means a timeout has occurred with a rollback. Positive means successful execution with a warning. An example is +100 which means no rows found. Here is a more comprehensive list of the SQLCODEs for DB2:

Zero (Successful)
0 Successful

Negative values (Errors)


-007 -010 -029 -060 -084 The specified 'character' is not a valid character in SQL statements. THE string constant beginning with string is not terminated properly. INTO Clause required. INVALID type SPECIFICATION : spec Unacceptable SQL statement.

-101 The statement is too long or too complex. -102 -117 -180 -181 -199 String constant is too long. The number of values in the INSERT does not match the number of columns. Bad data in Date/Time/Timestamp. Bad data in Date/Time/Timestamp. Illegal use of the specified keyword.

-204 -205 -206 -216 -224

Object not defined to DB2. Column name not in table. Column does not exist in any table of the SELECT. Not the same number of expressions on both sides of the comparison in a SELECT . FETCH cannot make an INSENSITIVE cursor SENSITIVE.

DB2 SQL return codes


-229 The locale specified in a SET LOCALE statement was not found.

-305 -311 -407 -482

Null indicator needed. Varchar, insert or update. -LEN field with the right data length not set. AN UPDATE, INSERT, OR SET VALUE IS NULL, BUT THE OBJECT COLUMN column-name CANNOT CONTAIN NULL VALUES The procedure returned no locators.

-501 -502 -503 -530 -532 -536 -545 -551

Cursor not open on FETCH. Opening cursor that is already open. Updating column needs to be specified. Referential integrity preventing the INSERT/UPDATE Referential integrity (DELETE RESTRICT rule) preventing the DELETE. Referential integrity (DELETE RESTRICT rule) preventing the DELETE. Check constraint preventing the INSERT/UPDATE. Authorization failure.

-602 -747 -803 -805 -811 -818

Too many columns specified in a create index. The table is not available. Duplicate key on insert or update. DBRM or package not found in plan. More than one row retrieved in SELECT INTO. Plan and program: timestamp mismatch.

-904 Unavailable resource. Someone else is locking your data. -911 Deadlock or timeout. Rollback has been done. -913 Deadlock or timeout. No rollback. -922 Authorization needed. -927 The language interface was called but no connection had been made. -936 -1741 -20000 -30090 Remote operation invalid for application execution environment.

Positive Values (Warnings)


+100 +222 +223 +231 +304 +802 Row not found or end of cursor. Trying to fetch a row within a DELETE statement. Trying to fetch a row within an UPDATE statement. FETCH after a BEFORE or AFTER but not on a valid row. Value cannot be assigned to this host variable because it is out of range. The null indicator was set to -2 as an arithmetic statement didn't work.

DB2 SQL return codes

References
"DB2 Version 9.1 for z/OS Codes" [1]. June 2010. "Tutorial on SQLCODES and Their Causes" [2]. July 2011.

References
[1] http:/ / publib. boulder. ibm. com/ infocenter/ dzichelp/ v2r2/ topic/ com. ibm. db29. doc. codes/ dsnc1k17. pdf?noframes=true [2] http:/ / theamericanprogrammer. com/ programming/ sqlcodes. shtml

Article Sources and Contributors

Article Sources and Contributors


DB2 SQL return codes Source: http://en.wikipedia.org/w/index.php?oldid=480560227 Contributors: Apokrif, Bachrach44, Crowne, Lavenderguy, Lpetrazickis, PhilKnight, RHaworth, ThanAngell, WOSlinker, Wallie, 12 anonymous edits

License
Creative Commons Attribution-Share Alike 3.0 Unported //creativecommons.org/licenses/by-sa/3.0/

Potrebbero piacerti anche