Oracle FORALL .. IN INDICES OF
This example shows the use of BULK COLLECT with "FORALL index IN INDICES OF collection" syntax to process the existing elements of a collection and skip the deleted index values.

DECLARE
 TYPE t_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
 v_bulk      t_tab;
 v_copy      t_tab;

 PROCEDURE p_bulk IS
 BEGIN
    SELECT level BULK COLLECT INTO v_bulk
    FROM  DUAL CONNECT BY level < 11;  
 END p_bulk;

BEGIN
 p_bulk;
 DBMS_OUTPUT.PUT_LINE(' Array Size = '||v_bulk.COUNT);

 v_bulk.DELETE(5);
 DBMS_OUTPUT.PUT_LINE(' Array Size = '||v_bulk.COUNT);

 FORALL idx IN INDICES OF v_bulk
   INSERT INTO load_sequence_lookup
    (load_sequence, load_id)
   SELECT v_bulk(idx), 1 FROM DUAL;

END;
/
--> Output

Oracle registered trademark of Oracle Corporation.

Last Revised On: 10/27/2013

  1323