DB2 SQL return codes

Last updated

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 programs. An important feature of IBM 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.

Contents

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 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:

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.

Zero (Successful)

0Successful

Negative values (Errors)

-007The specified 'character' is not a valid character in SQL statements.
-010THE string constant beginning with string is not terminated properly.
-029INTO Clause required.
-060INVALID type SPECIFICATION : spec
-084Unacceptable SQL statement.
-101The statement is too long or too complex.
-102String constant is too long.
-103String constant is too long. Max is 128 characters.
-104Illegal symbol encountered in the SQL statement.
-105String constant is too long.
-117The number of values in the INSERT does not match the number of columns.
-119Error in GROUP BY or HAVING clause.
-122Column or Expression in the Select List is not valid
-156Invalid syntax near keyword.
-180Bad data in Date/Time/Timestamp.
-181Bad data in Date/Time/Timestamp.
-188The host variable in a DESCRIBE statement is not a valid string representation of a name.
-199Illegal use of the specified keyword.
-203A REFERENCE TO COLUMN column-name IS AMBIGUOUS
-204Object not defined to Db2.
-205Column name not in table.
-206Column does not exist in any table of the SELECT.
-207Invalid column name.
-208THE ORDER BY CLAUSE IS INVALID BECAUSE COLUMN column-name IS NOT PART OF THE RESULT TABLE
-209Ambiguous column name
-216Not the same number of expressions on both sides of the comparison in a SELECT.
-224FETCH cannot make an INSENSITIVE cursor SENSITIVE.
-229The locale specified in a SET LOCALE statement was not found.
-257Implicit conversion in datatype is not allowed.
-289Db2 is running out of space in tablespace
-302THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE
-303A VALUE CANNOT BE ASSIGNED TO OUTPUT HOST VARIABLE NUMBER position-number BECAUSE THE DATA TYPES ARE NOT COMPARABLE
-305Null indicator needed.
-310The value of a decimal is null
-311Varchar, insert or update. -LEN field with the right data length not set.
-313The number of host variables specified is not equal to the number of parameter markers.
-401The data types of the operands of an operation are not compatible.
-404The Sql Statement specified contains a String that is too long.
-407AN UPDATE, INSERT, OR SET VALUE IS NULL, BUT THE OBJECT COLUMN column-name CANNOT CONTAIN NULL VALUES
-408A value is not compatible with the data type of its assignment target. Target name is "<name>". (***OBS: Para alguns casos o CAST resolve )
-413Overflow occurred during numeric data type conversion.
-414A like predicate is invalid because the first operand is not a string.
-415The corresponding columns, column-number, of the operands of a set operator are not compatible.
-418Use of parameter marker not valid.
-420The value of a string argument was not acceptable to the 'function-name' function
-421THE OPERANDS OF A UNION OR UNION ALL DO NOT HAVE THE SAME NUMBER OF COLUMNS
-433The data is too large
-438Application raised error with diagnostic text: text
-440Routine &1 in &2 not found with specified parameters.A function or procedure with the specified name and compatible arguments was not found.[1]
-482The procedure returned no locators.
-501Cursor not open on FETCH.
-502Opening cursor that is already open.
-503Updating column needs to be specified.
-504Cursor name not declared.
-510The Table designated by the cursor of the Update or Delete statement cannot be modified.
-530Referential integrity preventing the INSERT/UPDATE
-532Referential integrity (DELETE RESTRICT rule) preventing the DELETE.
-536Referential integrity (DELETE RESTRICT rule) preventing the DELETE.
-545Check constraint preventing the INSERT/UPDATE.
-551Authorization failure.
-554An authorization ID or a role cannot GRANT a privilege to itself.
-601You tried to create an object that already exists
-602Too many columns specified in a create index.
-603a unique index cannot be created because the table contains rows which are duplicates with respect to the values of the identified columns and periods
-604a data type definition specifies an invalid length, precision, or scale attribute
-607operation or option operation is not defined for this object
-610warning: a create/alter on object has placed object in pending
-611only lockmax 0 can be specified when the lock size of the tablespace is tablespace or table
-612identifier is a duplicate name
-613the primary key or a hash key or a unique constraint is too long or has too many columns and periods
-614the index cannot be created or altered, or the length of a column cannot be changed because the sum of the internal lengths of the columns for the index is greater than the allowable maximum
-615operation-type is not allowed on a package in use
-616obj-type1 obj-name1 cannot be dropped because it is referenced by obj-type2 obj-name2
-617a type 1 index is not valid for table
-618operation operation is not allowed on system databases
-619operation disallowed because the database is not stopped
-620keyword keyword in stmt-type statement is not permitted for a space-type space in the database-type database
-621duplicate dbid dbid was detected and previously assigned to database-name
-622for mixed data is invalid because the mixed data install option is no
-623cluster is not valid for table-name
-624table table-name already has a primary key or unique constraint with specified columns and periods
-625table table-name does not have an index to enforce the uniqueness of the primary or unique key
-625warning: the definition of table has been changed to incomplete
-626the alter statement is not executable because the page set is not stopped
-627the alter statement is invalid because the table space or index has user-managed data sets
-628the clauses are mutually exclusive
-629set null cannot be specified because foreign key name cannot contain null values
-630error: the WHERE NOT NULL specification is invalid for type 1 indexes
-631foreign key name is too long or has too many columns
-632the table cannot be defined as a dependent of table-name because of DELETE rule restrictions
-633the DELETE rule must be DELETE-rule
-634the DELETE rule must not be cascade
-635the DELETE rules cannot be different or cannot be set null
-636ranges specified for partition part-num are not valid
-637duplicate keyword-name keyword or clause
-638table table-name cannot be created because column definition is missing
-639a nullable column of a foreign key with a DELETE rule of set null cannot be a column of the key of a partitioned index
-640locksize row cannot be specified because table in this tablespace has type 1 index
-642too many columns in unique constraints
-643a check constraint or the value of an expression for a column of an index exceeds the maximum allowable length key expression
-644invalid value specified for keyword or clause keyword-or-clause in statement stmt-type
-645WHERE NOT NULL is ignored because the index key cannot contain null values
-646table table-name cannot be created in specified table space table-space-name because it already contains a table
-647bufferpool bp-name for implicit or explicit tablespace or indexspace name has not been activated
-650the alter statement cannot be executed, reason reason-code copyright 2014 TheAmericanProgrammer.com Unauthorized copying prohibited
-651table description exceeds maximum size of object descriptor.
-652violation of installation defined edit or validation procedure proc-name
-653table table-name in partitioned table space tspace-name is not available because its partitioned index has not been created
-655the create or alter stogroup is invalid because the storage group would have both specific and non-specific volume ids
-658a object-type cannot be dropped using the statement statement
-660index index-name cannot be created or altered on partitioned table space tspace-name because key limits are not specified
-661object-type object-name cannot be created on partitioned table space tspace-name because the number of partition specifications is not equal to the number of partitions of the table space
-662a partitioned index cannot be created on a table space, or a table space cannot be index-controlled. table space tspace-name, reason reason-code
-663the number of key limit values is either zero, or greater than the number of columns in the key of index index-name
-664the internal length of the limit-key fields for the partitioned index exceeds the length imposed by the index manager
-665the partition clause of an alter statement is omitted or invalid
-666stmt-verb object cannot be executed because function is in progress
-667the clustering index for a partitioned table space cannot be explicitly dropped
-668the column cannot be added to the table because the table has an edit procedure defined with row attribute sensitivity
-669the object cannot be explicitly dropped. reason reason-code
-670the record length of the table exceeds the page size limit
-671the bufferpool attribute of the table space cannot be altered as specified because it would change the page size of the table space
-672operation drop not allowed on table table_name
-676the physical characteristics of the index are incompatible with respect to the specified statement. the statement has failed. reason reason-code
-677insufficient virtual storage for bufferpool expansion
-678the constant specified for the index limit key must conform to the data type data-type of the corresponding column column-name
-679the object name cannot be created because a drop is pending on the object
-680too many columns specified for a table, view or table function
-681column column-name in violation of installation defined field procedure. rt: return-code, rs: reason-code, msg: message-token
-682field procedure procedure-name could not be loaded
-683the specification for column, distinct type, function, or procedure data-item contains incompatible clauses
-684the length of constant list beginning string is too long
-685invalid field type, column-name
-686column defined with a field procedure can not compare with another column with different field procedure
-687field types incomparable
-688incorrect data returned from field procedure, column-name, msgno
-689too many columns defined for a dependent table
-690the statement is rejected by data definition control support. reason reason-code
-691the required registration table table-name does not exist
-692the required unique index index-name for ddl registration table table-name does not exist
-693the column column-name in ddl registration table or index name is not defined properly
-694the schema statement cannot be executed because a drop is pending on the ddl registration table table-name
-694the ddl statement cannot be executed because a drop is pending on the ddl registration table
-695invalid value seclabel specified for security label column of table table-name
-696the definition of trigger trigger-name includes an invalid use of correlation name or transition table name name. reason code=reason-code
-697old or new correlation names are not allowed in a trigger defined with the for each statement clause. old_table or new_table names are not allowed in a trigger with the before clause.
-747The table is not available.
-803Duplicate key on insert or update.
-804Error in input parameters for the SQL statement.
-805DBRM or package not found in plan.
-811More than one row retrieved in SELECT INTO.
-818Plan and program: timestamp mismatch.
-902Pointer to Essential Control Block(RDA/CT) has value 0, Rebind Required. This may also occur if one of the DB volumes is still present, but inaccessible.
-904Unavailable resource. Someone else is locking your data.
-911Deadlock or timeout. Rollback has been done.
-913Deadlock or timeout. No rollback.
-922Authorization needed.
-924Db2 Connection internal error.
-927The language interface was called but no connection had been made.
-955Sort memory cannot be allocated to process the statement.
-964The transaction log space is depleted or temporary increase in the number of active transactions.
-970wrong (also missing) permissions on Db2 file systems / Db2 filesystems owned by root.
-998Error occurred during transaction or heuristic processing.
  
-2310The utility could not generate statistics
-3508Load Error accessing scratch space. Error in accessing a file or path of type "TEMP_FILE" during load or load query. The scratch directory where the msg files in a load job are stored does not have the required permissions.
-7008The object that is specified is not valid for the requested operation.
-10330Permission denied to change database. Contact system administrator.
-30090Remote operation invalid for application execution environment.

Positive Values (Warnings)

  +98A dynamic SQL statement ends with a semicolon
+100Row not found or end of cursor.
+222Trying to fetch a row within a DELETE statement.
+223Trying to fetch a row within an UPDATE statement.
+231FETCH after a BEFORE or AFTER but not on a valid row.
+304A value with data type (data type 1) cannot be assigned to a host variable because the value is not within the range of the host variable in position (position number) with data type (data type 2)
+354A rowset fetch statement may have returned one or more rows of data. however, one or more warning conditions were also encountered. use the get diagnostics statement for more information regarding the conditions that were encountered
+466The stored procedure named by proc completed normally. The procedure returned the number of SQL query result sets specified in num.
+562A grant of a privilege was ignored because the grantee already has the privilege from the grantor.
+802The null indicator was set to -2 as an arithmetic.

[1]

Related Research Articles

<span class="mw-page-title-main">MVS</span> Operating system for IBM mainframes

Multiple Virtual Storage, more commonly called MVS, is the most commonly used operating system on the System/370, System/390 and IBM Z IBM mainframe computers. IBM developed MVS, along with OS/VS1 and SVS, as a successor to OS/360. It is unrelated to IBM's other mainframe operating system lines, e.g., VSE, VM, TPF.

<span class="mw-page-title-main">IBM Db2</span> Relational model database server

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 and XML. The brand name was originally styled as DB/2, then DB2 until 2017 and finally changed to its present form.

Time Sharing Option (TSO) is an interactive time-sharing environment for IBM mainframe operating systems, including OS/360 MVT, OS/VS2 (SVS), MVS, OS/390, and z/OS.

A stored procedure is a subroutine available to applications that access a relational database management system (RDBMS). Such procedures are stored in the database data dictionary.

<span class="mw-page-title-main">Crash (computing)</span> When a computer program stops functioning properly and self-terminates

In computing, a crash, or system crash, occurs when a computer program such as a software application or an operating system stops functioning properly and exits. On some operating systems or individual applications, a crash reporting service will report the crash and any details relating to it, usually to the developer(s) of the application. If the program is a critical part of the operating system, the entire system may crash or hang, often resulting in a kernel panic or fatal system error.

<span class="mw-page-title-main">IBM Information Management System</span> Joint hierarchical database made by IBM

The IBM Information Management System (IMS) is a joint hierarchical database and information management system that supports transaction processing.

Job Control Language (JCL) is a name for scripting languages used on IBM mainframe operating systems to instruct the system on how to run a batch job or start a subsystem. The purpose of JCL is to say which programs to run, using which files or devices for input or output, and at times to also indicate under what conditions to skip a step. Parameters in the JCL can also provide accounting information for tracking the resources used by a job as well as which machine the job should run on.

Adabas, a contraction of “adaptable database system," is a database package that was developed by Software AG to run on IBM mainframes. It was launched in 1971 as a non-relational database. As of 2019, Adabas is marketed for use on a wider range of platforms, including Linux, Unix, and Windows.

An SQL INSERT statement adds one or more records to any single table in a relational database.

A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database. For example, when a new record is added to the employees table, new records should also be created in the tables of the taxes, vacations and salaries. Triggers can also be used to log historical data, for example to keep track of employees' previous salaries.

A user-defined function (UDF) is a function provided by the user of a program or environment, in a context where the usual assumption is that functions are built into the program or environment. UDFs are usually written for the requirement of its creator.

A relational database management system uses SQL MERGE statements to INSERT new records or UPDATE existing records depending on whether condition matches. It was officially introduced in the SQL:2003 standard, and expanded in the SQL:2008 standard.

SQLJ is a working title for efforts to combine Java and SQL. It was a common effort started around 1997 by engineers from IBM, Oracle, Compaq, Informix, Sybase, Cloudscape and Sun Microsystems.

SQL Processor Using File Input is a database facility invented by IBM for interfacing with their Db2 system. It is accessed from within TSO ISPF from the DB2I Primary Option menu.

SQL PL stands for Structured Query Language Procedural Language and was developed by IBM as a set of commands that extend the use of SQL in the IBM Db2 database system. It provides procedural programmability in addition to the querying commands of SQL. It is a subset of the SQL Persistent Stored Modules (SQL/PSM) language standard.

SQL:1999 was the fourth revision of the SQL database query language. It introduced many new features, many of which required clarifications in the subsequent SQL:2003. In the meanwhile SQL:1999 is deprecated.

A hierarchical query is a type of SQL query that handles hierarchical model data. They are special cases of more general recursive fixpoint queries, which compute transitive closures.

In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed.

In database management systems (DBMS), a prepared statement, parameterized statement, or parameterized query is a feature where the database pre-compiles SQL code and stores the results, separating it from data. Benefits of prepared statements are:

PL/SQL is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database, Times Ten in-memory database, and IBM Db2. Oracle Corporation usually extends PL/SQL functionality with each successive release of the Oracle Database.

References

  1. "IBM Docs".