December 2010
Intermediate to advanced
451 pages
11h 16m
English
Rather than iterating through a range of numbers by even increments, you prefer to loop through the range using odd increments.
Use the built-in MOD function to determine whether the current index is odd. If it is odd, then print out the value; otherwise, continue to the next iteration. The following example shows how to implement this solution:
BEGIN
FOR idx IN 1..10 LOOP
IF MOD(idx,2) != 0 THEN
DBMS_OUTPUT.PUT_LINE('The current index is: ' || idx);
END IF;
END LOOP;
END;
Results:
The current index is: 1
The current index is: 3
The current index is: 5
The current index is: 7
The current index is: 9
PL/SQL procedure successfully completed.
Read now
Unlock full access