Executes a block of statements while a specified condition remains true.
The CFL While statement creates a loop which executes the CFL statements contained in the DO clause, as long as the specified condition remains true.
The condition is evaluated before the loop is executed for the first time, and then every time the loop is about to be repeated. Since the condition is evaluated before the first execution, it is possible that the statement block will not be executed at all (if the condition is false on the initial evaluation).
You can create a While statement that never exits (an"endless loop). Always avoid this situation by making sure that the loop contains sufficient logic so that the condition will ultimately evaluate as false.
CFL includes two simple statements that can only be used inside the DO clause of a While statement: the Break statement, which forces an immediate exit from the loop, and the Continue statement, which interrupts the execution of the loop and forces an immediate re-evaluation of the WHILE condition.
Break Statement
Continue Statement
Here is an illustration of a While statement:
CREATE FUNCTION Pow(Value FLOAT, Power INTEGER) RETURNS FLOAT CREATE VARIABLE FLOAT Result =1; IF (Power < 0) THEN Power = -Power; Value = 1/Value END IF; WHILE 0 < Power DO Result = Result * Value Power = Power -1; END WHILE; RETURN Result; END FUNCTION;