PL/SQL For Loop

Oracle PL/SQL FOR LOOP Example

DECLARE
	CURSOR c1 is
	SELECT * FROM emp
	ORDER BY sal DESC;   
	v_c1 emp%ROWTYPE;    
BEGIN
	OPEN c1;
	FOR i IN 1..5 LOOP
		FETCH c1 INTO v_c1;
		EXIT WHEN c1%NOTFOUND;  
		INSERT INTO emp_test VALUES 
		(v_c1.empno, v_c1.ename, v_c1.job, v_c1.mgr, 
		v_c1.hiredate, v_c1.sal, v_c1.comm, v_c1.deptno);
	COMMIT;
	END LOOP;
	CLOSE c1;
END;