Introduction

The syntax for a FOR loop is as follows:

for <counter> in <lower_bound>..<higher_bound> 
loop  
     ...<<set of statements>>... 
end loop; 

Demo

SQL>
SQL> declare--  w w  w  .  ja  v  a  2 s  .co m
  2       v_current_nr NUMBER;
  3  begin
  4       v_current_nr:=0; -- should not be null!
  5        loop
  6             for inner_c in 1..4
  7             loop
  8                  DBMS_OUTPUT.put_line(v_current_nr);
  9             end loop;
 10             v_current_nr:=v_current_nr+5;
 11             exit when v_current_nr>25;
 12        end loop;
 13  end;
 14  /
0
0
0
0
5
5
5
5
10
10
10
10
15
15
15
15
20
20
20
20
25
25
25
25

PL/SQL procedure successfully completed.

SQL>

Related Topic