10th Example - FOR on PL/SQL
Other
operators that can be used in PL / SQL block for looping is FOR. Here is an example of using the
block operator FOR on PL/SQL block :
DECLARE
jumlah NUMBER:=10;
BEGIN
FOR i IN 1..jumlah LOOP
IF i MOD 2 = 0 THEN
DBMS_OUTPUT.PUT_LINE(i);
END IF;
END LOOP;
END;
/
Above
PL/SQL block will do the looping 10 times. Results shown are 2, 4, 6, 8 and 10 (even number). Odd numbers are not shown because there is an odd selection process even using MOD function.
Leave a Comment