Search code examples
oracleloopscursorfor-in-loop

Invalid cursor c1 when close for-in loop


FOR i in c1 LOOP
  UPDATE....
  COMMIT;
END LOOP;
CLOSE c1;

Above block hit error: Invalid c1 when CLOSE c1, updates are running well.Is it possible the cursor closed after loop is ended?


Solution

  • When you use syntax FOR xxx in c1 LOOP then the cursor is closed automatically at the end. You cannot close it twice.

    Just skip CLOSE c1;