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
- Test SQLCODE after each FETCH and only update or delete when a row was returned.
- Check what other cursors and statements in the program do to the same rows.
- Make the update or delete happen before the cursor moves on.
- 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