DB2 SQL Errors Codes and Error Messages and Warnings from Error -500 to -502

SQLServerF1

Error: DB2 SQL Error: SQLCODE=-500, SQLSTATE=24501, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE IDENTIFIED CURSOR WAS
CLOSED WHEN THE CONNECTION
WAS DESTROYED
Explanation: The FETCH, UPDATE, DELETE, or
CLOSE statement identifies a closed cursor that was
defined with the WITH HOLD option. The cursor was
closed when the connection on which it was dependent
was destroyed during a commit operation. The
connection was destroyed because the application
process placed it in the released state, or the application
plan was bound with the
DISCONNECT(AUTOMATIC) option.
System action: The statement cannot be executed.
Programmer response: The correction depends on the
desired state of both the cursor and the connection, as
follows:
v If you want the cursor closed, change the application
program so that the cursor is not referenced in the
closed state.
v If you want the cursor open and the connection was
placed in the released state by the application
program, change the program so that the connection
is not placed in the released state until the cursor is
explicitly closed.
v If you want the cursor open and the connection was
placed in the released state as a result of the
DISCONNECT(AUTOMATIC) option, rebind the
plan using DISCONNECT(CONDITIONAL).
Correct the error in the application, rebind the plan,
and resubmit the job.
SQLSTATE: 24501

Error: DB2 SQL Error: SQLCODE=-501, SQLSTATE=24501, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE CURSOR IDENTIFIED IN A
FETCH OR CLOSE STATEMENT IS
NOT OPEN
Explanation: The application program attempted
either to fetch using a cursor or to close a cursor at a
time when the specified cursor was not open.
System action: The statement cannot be processed.
Programmer response: Check for a previous SQL
return code that might have closed the cursor.
v Commit and rollback operations close cursors.
v SQL return codes -404, -652, -679, -802, -901, -904,
-909, -910, -911, -913, and -952 might force the cursor
to close.
After the cursor is closed, any fetches or close cursor
statements will receive SQLCODE -501.
If no previous SQL return codes have been issued,
correct the logic of the application program to ensure
that the cursor is open at the time the FETCH or
CLOSE statement is processed.
SQLSTATE: 24501

Error: DB2 SQL Error: SQLCODE=-502, SQLSTATE=24502, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE CURSOR IDENTIFIED IN AN
OPEN STATEMENT IS ALREADY
OPEN
Explanation: The application program attempted to
execute an OPEN statement for a cursor that was
already open.
System action: The statement cannot be executed. The
cursor was unchanged (that is, it was not ‘reopened’).
Programmer response: Correct the logic of the
application program to ensure that it does not attempt
to execute an OPEN statement for a cursor that is
already open.
SQLSTATE: 24502

Above are list of DB2 SQL Errors and Warnings from Error -500 to -502 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 *