Using a Reverse FOR..LOOP Statement
BEGIN
FOR i IN REVERSE 1..3 LOOP -- assign the values 1,2,3 to i
dbms_output.Put_line(To_char(i));
END LOOP;
END;
/
Inside a FOR loop, the counter can be read but cannot be changed.
BEGIN
FOR i IN 1.. 3 LOOP -- assign the values 1,2,3 to i
IF i < 3 THEN
dbms_output.Put_line(To_char(i));
ELSE
i := 2; -- not allowed, raises an error
END IF;
END LOOP;
END;
/
0 comments:
Post a Comment