Some languages provide a STEP clause, which lets you specify a different increment
(5 instead of 1 for example). PL/SQL has no such structure, but you can easily build
one. Inside the FOR loop, simply multiply each reference to the loop counter by the
new increment. In the following example, you assign today’s date to elements 5, 10,
and 15 of an index-by table:
DECLARE
TYPE DateList IS TABLE OF DATE INDEX BY BINARY_INTEGER;
dates DateList;
k CONSTANT INTEGER := 5; -- set new increment
BEGIN
FOR j IN 1..3 LOOP
dates(j*k) := SYSDATE; -- multiply loop counter by increment
END LOOP;
...
END;
关于步长可以这样处理,没有设置的地方的
FOR loop_index IN 1 .. 100
LOOP
IF MOD (loop_index, 2) = 0
THEN
/* We have an even number, so perform calculation */
calc_values (loop_index);
END IF;
END LOOP;