PL/I · DB2 SQLCODE
What does SQLCODE -502: Cursor Already Open mean in PL/I?
The PL/I program issued an OPEN for a cursor that's already open — typically because error handling didn't CLOSE the cursor on a prior failed path, or the same cursor is opened twice inside a loop without an intervening CLOSE.
The PL/I program issued an OPEN for a cursor that's already open — typically because error handling didn't CLOSE the cursor on a prior failed path, or the same cursor is opened twice inside a loop without an intervening CLOSE.
Add a CLOSE before re-opening the cursor (guarded by a check that it's actually open, or wrapped in its own error handling), and review the control flow for a path that skips CLOSE after an error.