Use label to mark outer loop and inner loop : Label « PL SQL « Oracle PL / SQL






Use label to mark outer loop and inner loop

   
SQL>
SQL>   BEGIN
  2          <<outerloop>>
  3          FOR v_outerloopcounter IN 1..2 LOOP
  4               <<innerloop>>
  5               FOR v_innerloopcounter IN 1..4 LOOP
  6                    DBMS_OUTPUT.PUT_LINE('Outer Loop counter is ' ||
  7                         v_outerloopcounter ||
  8                         ' Inner Loop counter is ' || v_innerloopcounter);
  9               END LOOP innerloop;
 10         END LOOP outerloop;
 11    END;
 12    /
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>
SQL>
SQL> --

   
    
  








Related examples in the same category

1.A labeled block.
2.Using labels with loops
3.Changing labeled loop execution with EXIT statements
4.Loop with a Label
5.Block with label