With the scenario below, the FOR LOOP will fail (... collection initialisation ...) if there are no records to delete.
What is the best way to deal with this without changing the delete-bulk collect statement?
... apart from wrapping the for loop in an exception block...
CREATE TABLE t_emp(id NUMBER, fname VARCHAR2(50));
DECLARE
TYPE t_emp IS TABLE OF employee%ROWTYPE;
c_emp t_emp;
BEGIN
DELETE FROM emp
RETURNING id, fname BULK COLLECT INTO c_emp;
FOR i IN 1..c_emp.COUNT LOOP
dbms_output.put_line (' rows found');
END LOOP;
END;
Thanks