-- bulk_return.sql

DROP TABLE testoutput
/

CREATE TABLE testoutput ( output NUMBER )
/

DECLARE
   TYPE emp_num_type IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
   deleted_emps emp_num_type;
BEGIN
     DELETE FROM employee
      WHERE store_number IS NULL
  RETURNING id BULK COLLECT INTO deleted_emps;
   FOR i IN 1..deleted_emps.COUNT LOOP
     INSERT INTO testoutput (output)
            VALUES ( deleted_emps(i) );
   END LOOP;
END;
/

SELECT output FROM testoutput
/


