Cursor FOR Loops
Oracle Fusion / EBS · Technical · PL/SQL
GeneralHigh confidence
Implicitly opens, fetches into a record, and closes the cursor — no explicit OPEN/FETCH/CLOSE needed.
Grounded in: Curated Oracle knowledge layer — PL/SQL
How it works
A cursor FOR loop implicitly opens the cursor, fetches into an implicitly declared record each iteration, and closes the cursor automatically once the loop ends (including on an early EXIT) — no explicit OPEN/FETCH/CLOSE and no %NOTFOUND check needed. That's why it's the preferred, less error-prone style for a straightforward row-by-row pass over a query.
How it works
BEGIN
FOR r_employee IN (
SELECT employee_id, last_name, salary FROM employees WHERE department_id = 90
) LOOP
DBMS_OUTPUT.PUT_LINE(r_employee.last_name || ': ' || r_employee.salary);
END LOOP;
END;
/Related Questions
Have a follow-up, or a different question?
Continue in Ask Oracle AI