IF Condition THEN
8.8.2 WHILE Loops
The WHILE loop executes as long as the mentioned Boolean condition evaluates to TRUE.
It has the following syntax:
WHILE condition LOOP
The reserved word WHILE is used to start a loop construct. Then condition is evaluated
to TRUE or FALSE. The result of evaluation decides whether the loop is executed or not.
Statements 1 through n, are executed repeatedly. The END LOOP is a reserved phrase used
to terminate loop construct.
Example 7: Print numbers from 1 to 10
counter NUMBER := 1;
WHILE counter <= 10 LOOP
DBMS_OUTPUT.PUT_LINE (' '||counter);
counter := counter + 1;
8.8.3 FOR Loop
A numeric FOR loop is called numeric because it needs an integer value to terminate loop.
The numeric FOR loop is the traditional and familiar “counted” loop. The number of it-
erated of the FOR loop is known when the loop starts; it is specified in the range scheme
found between the FOR and LOOP keywords in the boundary. Do not declare the loop
index. PL/SQL automatically and implicitly declares it as a local variable with datatype
INTEGER. It has the following syntax:
FOR loop_counter IN [REVERSE] lowest_number ....highest_number LOOP