EXIT statement with Label : EXIT « PL SQL Statements « Oracle PL/SQL Tutorial






SQL>
SQL> set serveroutput on
SQL> set echo on
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 ' ||
  9                                          v_innerloopcounter);
 10                    EXIT outerloop WHEN v_innerloopcounter = 3;
 11              END LOOP innerloop;
 12         END LOOP outerloop;
 13    END;
 14    /
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>








22.8.EXIT
22.8.1.EXIT a WHILE LOOP
22.8.2.EXIT WHEN
22.8.3.EXIT a FOR LOOP
22.8.4.Exit a function
22.8.5.EXIT statement with Label
22.8.6.Using 'EXIT WHEN' in a loop
22.8.7.EXIT a LOOP WHEN a certain condition
22.8.8.Exit to a Label