oracle不支持,但支持步长为-1的

解决方案 »

  1.   

    只能自己实现
    例如:步长为2
    for i in min_value .. max_value loop
      if mod(i,2)=0 then
      // do something here...
    end loop;
      

  2.   

    有道理,谢谢 yxxx(小孬) ,这招阴.
      

  3.   

    下面是从oracle 9.2的文档(B10501_01)中copy的:
    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;