Database Reference
In-Depth Information
END IF;
DBMS_OUTPUT.PUT_LINE(TO_CHAR(OUTER)||' '||TO_CHAR(INNER));
END LOOP;
END LOOP outerloop;
DBMS_OUTPUT.PUT_LINE('Done with nested FOR loops');
END;
/
Note: Forcing control out of a loop using an EXIT command is poor mod-
ular programming practice. Doing the same from more than a single nested
loop level is worse, but it can be done in PL/SQL.
24.7.2.2
The WHILE Loop
The WHILE loop is executed as long as a condition at the start of the loop
is false and can be aborted using the EXIT WHEN clause. WHILE loop
syntax is shown in Figure 24.19.
The example WHILE loop following will iterate through the loop nine
times. The variable STEP starts at 1 because of the DEFAULT 1 clause in
the variable definition. When the WHILE loop condition reaches 10, the
condition fails and control is passed to the line after the END LOOP state-
Figure 24.19
WHILE Loop
Statement Syntax.
ment (the WHILE loop counts from 1 to 9). An example screenshot is not
included for this example as with the FOR loop examples.
DECLARE
STEP INTEGER DEFAULT 1;
 
Search WWH ::




Custom Search