22. 4. 1. FOR Loops |
|
A FOR loop runs a predetermined number of times. |
The syntax for a FOR loop is as follows: |
FOR loop_variable IN [REVERSE] lower_bound..upper_bound LOOP
statements
END LOOP;
|
|
where |
- loop_variable specifies the loop variable.
- REVERSE specifies that the loop variable value is to be decremented each time through the loop.
- lower_bound specifies the loop's lower bound.
- upper_bound specifies the loop's upper bound.
- If REVERSE is used, the loop variable is initialized to this upper bound.
|
SQL>
SQL> set serveroutput on
SQL> BEGIN
2 FOR just_a_num IN 1..10
3 LOOP
4 dbms_output.put_line(just_a_num);
5 END LOOP;
6 END;
7 /
1
2
3
4
5
6
7
8
9
10
PL/SQL procedure successfully completed.
SQL>
|
|