Implicit Cursor vs Explicit Cursor - Oracle DB
A cursor can be explicit or implicit, and either type can be used in a FOR loop. Why use an explicit cursor FOR loop over an implicit cursor FOR loop? Use an explicit cursor FOR loop when the query will be reused, otherwise an implicit cursor is preferred. Why use a loop with a FETCH rather than a FOR loop that doesn’t have an explicit FETCH? Use a FETCH inside a loop when you need to bulk collect or when you need dynamic SQL. Here is some useful information from the documentation. Example of Implicit Cursor FOR LOOP BEGIN FOR vItems IN ( SELECT last_name FROM employees WHERE manager_id > 120 ORDER BY last_name ) LOOP DBMS_OUTPUT . PUT_LINE ( 'Name = ' || vItems . last_name ); END LOOP ; END ; / Example of Explicit Cursor FOR LOOP DECLARE CURSOR c1 IS SELECT last_name FROM employees WHERE manager_id > 120 ORDER BY last_name ; BEGIN FOR vItems I...