Changing labeled loop execution with EXIT statements : Label « PL SQL « Oracle PL / SQL






Changing labeled loop execution with EXIT statements

  

SQL>
SQL> -- Changing labeled loop execution with EXIT statements.
SQL> BEGIN
  2        <<outerloop>>
  3        FOR i IN 1..2 LOOP
  4             <<innerloop>>
  5             FOR j IN 1..4 LOOP
  6                  DBMS_OUTPUT.PUT_LINE('Outer Loop counter is ' || i || ' Inner Loop counter is ' || j);
  7                       EXIT outerloop WHEN j = 3;
  8             END LOOP innerloop;
  9        END LOOP outerloop;
 10  END;
 11   /
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>
           
         
    
  








Related examples in the same category

1.A labeled block.
2.Using labels with loops
3.Use label to mark outer loop and inner loop
4.Loop with a Label
5.Block with label