December 2010
Intermediate to advanced
451 pages
11h 16m
English
You are working with a range of numbers and want to iterate backward through the range, from the upper bound to the lower bound.
Use a FOR loop along with the REVERSE keyword to iterate backward through the range. In this example, the same solution that was shown in Recipe 3-9 has been modified to iterate backward through the range of numbers.
BEGIN
FOR idx IN REVERSE 1..10 LOOP
DBMS_OUTPUT.PUT_LINE('The current index is: ' || idx);
END LOOP;
END;
Here is the result:
The current index is: 10
The current index is: 9
The current index is: 8
The current index is: 7
The current index is: 6
The current index is: 5
The current index is: 4
The current index is: 3 The current index ...Read now
Unlock full access