PL/SQL For Loop

PL/SQL For Loop

Example 1:

DECLARE
	x number:=0;
BEGIN
	FOR i IN 1 .. 5 
	LOOP 
		x:= i; 
		DBMS_OUTPUT.PUT_LINE (' x= ' || x);
	END LOOP;
END;

Example 2:

BEGIN
	FOR i IN 1 .. 5 
	LOOP 
		IF i NOT IN (1,5) THEN 
			DBMS_OUTPUT.PUT_LINE ('i = ' || i);
		END IF;
	END LOOP;
END;