title: Which is better - Cursor For Loop or Loop over PLSQL collection populated by Bulk Collect?
body: <p>Which of them is more performant.</p>
  
  <p><strong>Version 1</strong> uses <code>Cursor For Loop</code></p>
  
  <pre><code>DECLARE
    total_val number(6);
  
    CURSOR c1 IS
    SELECT * FROM emp
    ;
  BEGIN
    total_val := 0;
    FOR emp_rec IN c1
    LOOP
      total_val := total_val + emp_rec.sal;
    END LOOP;
  
    DBMS_OUTPUT.PUT_LINE('TOTAL SALARIES: ' || total_val);
  END;
  </code></pre>
  
  <p><strong>Version 2</strong> first uses <code>Bulk Collect</code> to get all rows into PLSQL collection then iterates over it.</p>
  
  <pre><code>DECLARE
    total_val number(6);
  
    CURSOR c1 IS
    SELECT * FROM emp
    ;
  
    TYPE emp_recs_type IS TABLE OF emp%ROWTYPE;
    emp_recs emp_recs_type;
  BEGIN
    total_val := 0;
  
    OPEN c1;
    FETCH c1 BULK COLLECT INTO emp_recs;
    CLOSE c1;
  
    FOR l_index IN emp_recs.FIRST..emp_recs.LAST
    LOOP
      total_val := total_val + emp_recs(l_index).sal;
    END LOOP;
  
    DBMS_OUTPUT.PUT_LINE('TOTAL SALARIES: ' || total_val);
  END;
  </code></pre>
  
  <p>Please assume that the <code>Cursor</code> might return many rows, could be in 10s of thousands or more.</p>