RPG (IBM i / AS/400) · DB2 SQLCODE
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.
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.
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.