|Oracle® OLAP DML Reference
11g Release 1 (11.1)
|PDF · Mobi · ePub|
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.
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 for as long as 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.
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.
In the following program lines, the statements following DO are executed as long as 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 will never end.
WHILE count LT 10 DO ..." (statements) IF .... count = count + 1 DOEND