Exit outer loop with 'EXIT LabelName When' statement : EXIT « PL SQL « Oracle PL / SQL






Exit outer loop with 'EXIT LabelName When' statement

  
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                         EXIT outerloop WHEN v_innerloopcounter = 3;
 10              END LOOP innerloop;
 11         END LOOP outerloop;
 12    END;
 13    /
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

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> --

   
  








Related examples in the same category

1.Impact of EXIT in a function
2.Using EXIT with a simple LOOP
3.Using EXIT with a WHILE loop
4.Using EXIT with a FOR loop
5.Unconstrained loop: exit
6.EXIT WHEN clause.
7.Exit to a label
8.Exit loop since last index value is read.