Example 1: Using a Reverse Loop SQL> SET FLAGS 'TRACE'; SQL> BEGIN cont> DECLARE :LOOP_VAR INTEGER; cont> FOR :LOOP_VAR IN REVERSE 1 TO 5 cont> DO cont> TRACE :LOOP_VAR; cont> END FOR; cont> END; ~Xt: 5 ~Xt: 4 ~Xt: 3 ~Xt: 2 ~Xt: 1 Example 2: Using an INTERVAL type as the loop variable SQL> begin cont> declare :i interval year; cont> for :i in (interval'1' year) to (interval'4'year) cont> do cont> trace :i; cont> end for; cont> end; ~Xt: 01 ~Xt: 02 ~Xt: 03 ~Xt: 04 Example 3: Using a complex expression as the STEP expression SQL> begin cont> declare :i interval year; cont> declare :k interval year = interval'18'year; cont> declare :j integer = 2; cont> cont> for :i in (interval'1' year) to :k/2 step :j*2 cont> do cont> trace :i; cont> end for; cont> end; ~Xt: 01 ~Xt: 05 ~Xt: 09