Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Statements
 

Nested FOR loop counter

SQL> SQL> set serveroutput on SQL> set echo on SQL> SQL> BEGIN   2       FOR v_outerloopcounter IN 1..2 LOOP   3            FOR v_innerloopcounter IN 1..4 LOOP   4                 DBMS_OUTPUT.PUT_LINE('Outer Loop counter is ' ||   5                      v_outerloopcounter ||   6                      ' Inner Loop counter is ' || v_innerloopcounter);   7            END LOOP;   8       END LOOP;   9  END;  10  / Outer Loop counter is 1 Inner Loop counter is 1 Outer Loop counter is 1 Inner Loop counter is 2 Outer Loop counter is 1 Inner Loop counter is 3 Outer Loop counter is 1 Inner Loop counter is 4 Outer Loop counter is 2 Inner Loop counter is 1 Outer Loop counter is 2 Inner Loop counter is 2 Outer Loop counter is 2 Inner Loop counter is 3 Outer Loop counter is 2 Inner Loop counter is 4 PL/SQL procedure successfully completed. SQL>