Dynamic Ranges
The PL/SQL lets you determine the loop range dynamically at run time, as the example below shows:
SELECT COUNT(empno) INTO emp_count FROM emp;
FOR i IN 1..emp_count LOOP
...
END LOOP;
The value of emp_count is unknown at the compile time; the SELECT statement returns the value at the run time.