Learn it on Mainframe Path. Do it with Mainframe KIT.Learn on Mainframe Path ▸
Mainframe KIT ● Nothing leaves this tab

-508

Cursor is not positioned on a row that can be updated or deletedNEGATIVE SQLCODE · CHECKED 2026-11-07
Checked against IBM documentation

UPDATE or DELETE WHERE CURRENT OF ran while the cursor was not on a row of the table, so nothing was changed.

QUICK ANSWER

UPDATE or DELETE WHERE CURRENT OF ran while the cursor was not on a row of the table, so nothing was changed.

LIKELY CAUSES, IN THE ORDER OF THIS ENTRY

  1. The last FETCH returned SQLCODE +100, so the cursor is not on a row.
  2. Another cursor in the same program deleted the row, or updated an index column of it.
  3. A rollback to a savepoint performed a delete or an index column update that moved the cursor off its row.
  4. With a sensitive dynamic cursor and FOR ROW n OF ROWSET, the chosen row of the current rowset was already updated or deleted.

CHECKED 7 Nov 2026 IBM: Db2 13 for z/OS Codes: -508

MOST LIKELY

The last FETCH returned SQLCODE +100, so the cursor is not on a row.

FIRST CHECK

Test SQLCODE after each FETCH and only update or delete when a row was returned.

TRY IT ▸

Site search

What it means

A positioned UPDATE or DELETE acts on the row the cursor is currently on. If the cursor is not on a row, for example after a FETCH that returned +100, or because another cursor in the same program deleted that row, Db2 cannot tell which row to change and rejects the statement.

The cursor position stays as it was and no data is updated or deleted.

Typical causes

  • The last FETCH returned SQLCODE +100, so the cursor is not on a row.
  • Another cursor in the same program deleted the row, or updated an index column of it.
  • A rollback to a savepoint performed a delete or an index column update that moved the cursor off its row.
  • With a sensitive dynamic cursor and FOR ROW n OF ROWSET, the chosen row of the current rowset was already updated or deleted.

How to fix it

  1. Test SQLCODE after each FETCH and only update or delete when a row was returned.
  2. Check what other cursors and statements in the program do to the same rows.
  3. Make the update or delete happen before the cursor moves on.
  4. Rerun after correcting the program logic.

Example

Illustrative only; names and values are invented.

SQLCODE = -508, SQLSTATE 24504
-- UPDATE ... WHERE CURRENT OF C1 after a FETCH returned +100