DB2 SQL Errors Codes and Error Messages and Warnings from Error -514 to -517

SQLServerF1

Error: DB2 SQL Error: SQLCODE=-514, SQLSTATE=26501, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE CURSOR cursor-name IS NOT IN A
PREPARED STATE
Explanation: The application program has tried to use
a cursor, ‘cursor-name,’ that is not in a prepared state.
The cursor is associated with a statement that either (1)
has never been prepared, or (2) has been invalidated by
a commit or rollback operation.
System action: The statement cannot be executed.
Programmer response: For case (1), ensure that you
prepare the statement that is named in the DECLARE
CURSOR statement for ‘cursor-name’ before you try to
open the cursor. For case (2), do one of the following:
v Use the WITH HOLD option of DECLARE CURSOR.
v Do not execute a commit or rollback operation until
you are finished using the cursor.
v Prepare the statement again after the commit or
rollback.
SQLSTATE: 26501

Error: DB2 SQL Error: SQLCODE=-516, SQLSTATE=26501, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE DESCRIBE STATEMENT DOES
NOT SPECIFY A PREPARED
STATEMENT
Explanation: An attempt was made to execute a
DESCRIBE statement that did not refer to a statement
that had been successfully prepared at the current
server.
System action: The statement cannot be executed.
Programmer response: Verify that the statement name
specified in the DESCRIBE statement is a statement that
has been prepared at the current server.
SQLSTATE: 26501

Error: DB2 SQL Error: SQLCODE=-517, SQLSTATE=07005, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
CURSOR cursor-name CANNOT BE
USED BECAUSE ITS STATEMENT
NAME DOES NOT IDENTIFY A
PREPARED SELECT STATEMENT
Explanation: The cursor ‘cursor-name’ could not be
used as specified because the prepared statement
named in the declaration for the cursor was not a
SELECT statement.
System action: The statement cannot be executed.
Programmer response: Verify that the statement-name
is specified correctly in the PREPARE statement and the
DECLARE CURSOR statement for cursor ‘cursor-name’.
Alternatively, correct the application program logic to
ensure that only prepared SELECT statements are used
in association with cursor declarations.
SQLSTATE: 07005

Above are list of DB2 SQL Errors and Warnings from Error -514 to -517 received while performing certain operation against DB2 Database or related products.

SQLCODE – Regardless of whether the application program provides an SQLCA or a stand-alone variable, SQLCODE is set by DB2 after each SQL statement is
executed. DB2 conforms to the ISO/ANSI SQL standard as follows:
If SQLCODE = 0, execution was successful.
If SQLCODE > 0, execution was successful with a warning.
If SQLCODE < 0, execution was not successful.
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.

SQLSTATE – SQLSTATE is also set by DB2 after the execution of each SQL statement. Thus, application programs can check the execution of SQL statements by testing SQLSTATE instead of SQLCODE.

Hope this was helpful.

Thanks,
SQLServerF1 Team
Information about DB2 SQL Error Codes and Error Messages on Windows, Linux and Z/OS Operating Systems.

 

Leave a Reply

Your email address will not be published. Required fields are marked *