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

SQLCODE -502 - Cursor Already Open

What does SQLCODE -502 - Cursor Already Open mean in RPG (IBM i / AS/400)?

An OPEN was issued for a cursor that is already open, typically because the program looped back to the OPEN statement without an intervening CLOSE.

SQLCODE -502 - Cursor Already OpenDB2 for i · SQLRPGLE

Condition

An OPEN was issued for a cursor that is already open, typically because the program looped back to the OPEN statement without an intervening CLOSE.

Fix

CLOSE the cursor before re-opening it, or restructure the subroutine so OPEN executes only once per logical pass and reuses the already-open cursor for repositioning instead.

Related db2 sqlcode