What it means
When a cursor is declared with a FOR UPDATE clause, only the columns named there can be changed by UPDATE ... WHERE CURRENT OF. The program tried to set a column outside that list, so Db2 refuses the statement and leaves the table untouched.
This is a mismatch between the cursor declaration and the later UPDATE, so the fix is in the program source.
Typical causes
- The UPDATE sets a column that was left out of FOR UPDATE OF in DECLARE CURSOR.
- The column list in FOR UPDATE OF was edited later without changing the UPDATE.
- Two cursors were mixed up, one with a shorter column list.
- An UPDATE statement was copied from another program with a different cursor.
How to fix it
- Compare the SET columns of the UPDATE with the FOR UPDATE OF list of the cursor.
- Add the missing column name to FOR UPDATE OF in the cursor declaration, or remove it from SET.
- Check that the UPDATE names the cursor you meant in WHERE CURRENT OF.
- Precompile and rerun.
Example
Illustrative only; names and values are invented.
SQLCODE = -503, SQLSTATE 42912
-- cursor: FOR UPDATE OF SALARY, but the UPDATE sets BONUS