RPG (IBM i / AS/400) · DB2 SQLCODE

SQLCODE -508 - Cursor Not Positioned on a Row

What does SQLCODE -508 - Cursor Not Positioned on a Row mean in RPG (IBM i / AS/400)?

An UPDATE ... WHERE CURRENT OF or DELETE ... WHERE CURRENT OF was issued against a cursor that isn't currently positioned on a row - for example after a FETCH returned SQLCODE 100, or before the first FETCH was ever done.

SQLCODE -508 - Cursor Not Positioned on a RowDB2 for i · SQLRPGLE

Condition

An UPDATE ... WHERE CURRENT OF or DELETE ... WHERE CURRENT OF was issued against a cursor that isn't currently positioned on a row - for example after a FETCH returned SQLCODE 100, or before the first FETCH was ever done.

Fix

Only issue the WHERE CURRENT OF statement immediately after a FETCH that returned SQLCODE 0, and skip the update/delete whenever the previous FETCH hit end-of-data.

Related db2 sqlcode