DB2 SQL Errors Codes and Error Messages and Warnings from Error -508 to -510

SQLServerF1

Error: DB2 SQL Error: SQLCODE=-508, SQLSTATE=24504, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE CURSOR IDENTIFIED IN THE
UPDATE OR DELETE STATEMENT IS
NOT POSITIONED ON A ROW OR
ROWSET THAT CAN BE UPDATED
OR DELETED
Explanation: The application program attempted to
execute an UPDATE or DELETE WHERE CURRENT
OF cursor statement at a time when the specified
cursor was not positioned on a row or rowset of the
object table. The cursor must be positioned on the row
that is to be updated or deleted.
This can occur if the cursor is no longer positioned on
the row because another cursor in the same application
program delete the row or updates an index column.
This includes deletes and index column updates that
are performed as a result of rolling back to a savepoint.
This can also occur with a sensitive dynamic cursor
when the FOR ROW n OF ROWSET clause is specified
and the specified row of the current rowset has been
updated or deleted.
System action: The statement cannot be executed. No
data was updated or deleted, and the cursor position is
unchanged.
Programmer response: Correct the logic of the
application program to ensure that the cursor is
correctly positioned on the intended row of the object
table before the UPDATE or DELETE statement is
executed. Note that for single row or non-rowset
cursors, the cursors are not positioned on a row if
FETCH returned SQLCODE +100.
SQLSTATE: 24504

Error: DB2 SQL Error: SQLCODE=-509, SQLSTATE=42827, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE TABLE IDENTIFIED IN THE
UPDATE OR DELETE STATEMENT IS
NOT THE SAME TABLE DESIGNATED
BY THE CURSOR
Explanation: The application program attempted to
execute an UPDATE or DELETE WHERE CURRENT
OF cursor statement where the table named in that
statement did not match the name of the table specified
in the declaration for that cursor.
System action: The statement cannot be executed. The
update or delete was not performed.
Programmer response: Correct the application
program to ensure that the table identified in the
UPDATE or DELETE statement is the same table
identified in the declaration for the cursor.
SQLSTATE: 42827

Error: DB2 SQL Error: SQLCODE=-510, SQLSTATE=42828, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE TABLE DESIGNATED BY THE
CURSOR OF THE UPDATE OR
DELETE STATEMENT CANNOT BE
MODIFIED
Explanation: The application program attempted to
execute an UPDATE or DELETE WHERE CURRENT
OF cursor statement against a table or view that cannot
be updated or deleted. This error can be returned for
the following reasons:
v A delete was performed from a read-only view or for
an update in which the cursor was not defined with
the FOR UPDATE clause.
v A target table exists at a remote location and DB2 has
employed block fetching because you explicitly
declared the cursor FOR FETCH ONLY, or because
the application is bound CURRENTDATA( NO) and
the cursor is ambiguous.
v DB2 has employed parallelism to execute the
SELECT statement associated with the cursor named
in a DELETE WHERE CURRENT OF cursor
statement, or a DELETE WHERE CURRENT OF is
issued against a row which DB2 cannot guarantee to
have not been modified by another application since
the time the cursor was positioned upon it (in
accordance with ISO(CS)) semantics for an
ambiguous cursor in an application bound
CURRENTDATA(NO)).
v The cursor references a view on which an INSTEAD
OF UPDATE trigger is defined, even if the view is an
updatable view.
System action: The statement cannot be processed. No
data was updated or deleted in the object table or view.
Programmer response: The requested UPDATE or
DELETE cannot be performed. Refer to chapter 2 of
SQL Reference for information about restrictions on
using UPDATE and DELETE operations against views.
For a remote table, modify the DECLARE CURSOR
and then rebind the PLAN.
For a cursor that uses parallelism, disable parallelism
for the query by using the DEGREE(1) BIND option for
static SQL or by setting the CURRENT DEGREE special
register to ‘1’ for dynamic SQL.
For an ambiguous cursor in an application bound
CURRENTDATA(NO), either make the cursor
unambiguous (declare it FOR UPDATE OF), or rebind
the application CURRENTDATA(YES).
For a view with INSTEAD OF triggers, drop those
triggers.
SQLSTATE: 42828

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