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

SQLCODE -906 - Cursor Disabled by a Previous Error

What does SQLCODE -906 - Cursor Disabled by a Previous Error mean in RPG (IBM i / AS/400)?

A FETCH or other operation was attempted against a cursor that SQL already disabled because an earlier statement error occurred on that same cursor, so SQL refuses further operations against it until it's reopened.

SQLCODE -906 - Cursor Disabled by a Previous ErrorDB2 for i · SQLRPGLE

Condition

A FETCH or other operation was attempted against a cursor that SQL already disabled because an earlier statement error occurred on that same cursor, so SQL refuses further operations against it until it's reopened.

Fix

Stop processing the fetch loop as soon as a real error (not just SQLCODE 100) is detected, and CLOSE then re-OPEN the cursor before attempting to use it again.

Related db2 sqlcode