unconstrained loop : Loop « PL SQL « Oracle PL / SQL






unconstrained loop

  
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.Use EXIT WHEN to exit a loop
2.Empty Loop statement
3.Loop with label
4.LOOP..END LOOP, Cursor Loop
5.Insert a row into MyTable with the current value of the loop counter.
6.An anonymous block demonstrates a guard on exit simple loop