Unconstrained loop: exit : EXIT « PL SQL « Oracle PL / SQL






Unconstrained loop: exit

 

SQL>
SQL> -- unconstrained loop: exit
SQL>
SQL>  declare
  2      l_loops number := 0;
  3    begin
  4      dbms_output.put_line('Before my loop');
  5
  6      loop
  7        if l_loops > 4 then
  8          exit;
  9        end if;
 10        dbms_output.put_line('Looped ' || l_loops || ' times');
 11        l_loops := l_loops + 1;
 12      end loop;
 13
 14      dbms_output.put_line('After my loop');
 15    end;
 16    /
Before my loop
Looped 0 times
Looped 1 times
Looped 2 times
Looped 3 times
Looped 4 times
After my loop

PL/SQL procedure successfully completed.

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.Exit outer loop with 'EXIT LabelName When' statement
6.EXIT WHEN clause.
7.Exit to a label
8.Exit loop since last index value is read.