|Oracle® OLAP DML Reference
11g Release 2 (11.2)
Part Number E17122-05
Serves as the criterion for statement execution. While the expression remains
TRUE, statement is repeatedly executed. When the expression becomes
FALSE, the execution of statement ceases, and the program continues with the next line. Ensure that something in the statement (or statements) eventually causes the Boolean expression to become
FALSE; otherwise, the code becomes an endless loop.
One or more statements to be executed while the Boolean expression is
TRUE. You can execute two or more statements by enclosing them within DO ... DOEND brackets. The DO statement should follow immediately after the WHILE statement.
WHILE Compared to IF
The WHILE statement's main use is as an alternative to the IF...THEN...ELSE comand.When you want one or more statements in your program to execute repeatedly while a Boolean expression remains
TRUE, you use WHILE. When you want them to execute only once when a Boolean expression is
TRUE, you use IF.
You can specify a constant for the Boolean expression. When your statement is WHILE TRUE, make sure to include a BREAK, RETURN, or EXIT statement between DO ... DOEND so the program can finish the loop.
Branching in a Loop
You can use the BREAK, CONTINUE, and GOTO commands to branch within, or out of, a WHILE loop, thereby altering the sequence of statement execution.
Example 10-176 Using a WHILE Loop in a Program
In the following program lines, the statements following DO are executed when the Boolean expression
TRUE. Within the loop, the code searches for an instance of some condition and, when it finds one, it adds
10, the loop ends. The code in the loop must ensure that
count will, at some time, reach
10. Otherwise, the loop never ends
WHILE count LT 10 DO ..." (statements) IF .... count = count + 1 DOEND