December 2010
Intermediate to advanced
451 pages
11h 16m
English
You want to iterate over a series of statements until a specified condition no longer evaluates to TRUE.
Use a WHILE statement to test the condition, and execute the series of statements if the condition evaluates to TRUE; otherwise, skip the statements completely. The following example shows a WHILE statement evaluating the current value of a variable and looping through until the value of the variable reaches ten. Within the loop, this variable is being multiplied by two and printing out its current value.
DECLARE
myValue NUMBER := 1;
BEGIN
WHILE myValue < 10 LOOP
DBMS_OUTPUT.PUT_LINE('The current value is: ' || myValue);
myValue := myValue * 2; END LOOP; ...Read now
Unlock full access