Specifying FOR LOOP Statement Bounds at Run Time
SQL> SQL> CREATE TABLE temp ( 2 emp_no NUMBER, 3 email_addr VARCHAR2(50)-- from ww w . java 2 s .c o m 4 ); SQL> SQL> DECLARE 2 emp_count NUMBER; 3 BEGIN 4 SELECT COUNT(empid) INTO emp_count 5 FROM emp; 6 7 FOR i IN 1..emp_count LOOP 8 INSERT INTO temp (emp_no, email_addr) 9 VALUES(i, 'to be added later'); 10 END LOOP; 11 END; 12 / PL/SQL procedure successfully completed. SQL>