DECLARE
CURSOR emp_cur IS
SELECT empno,ename,job,mgr,hiredate,sal,comm,deptno
FROM scott.emp;
emp_rec emp_cur%ROWTYPE;
TYPE emp_type
IS TABLE OF emp_cur%ROWTYPE INDEX BY BINARY_INTEGER;
emp_tab EMP_TYPE;
counter INTEGER := 0;
PROCEDURE Printemployeesdetails(emp_row EMP_TYPE)
IS
BEGIN
FOR i IN emp_row.first..emp_row.last LOOP
dbms_output.Put_line(Emp_row(i).empno|| ' - '|| Emp_row(i).ename|| ' - '|| Emp_row(i).job|| ' - '|| Emp_row(i).mgr|| ' - '|| Emp_row(i).hiredate|| ' - '|| Emp_row(i).sal|| ' - '|| Emp_row(i).comm|| ' - '|| Emp_row(i).deptno);
END LOOP;
END;
BEGIN
OPEN emp_cur;
LOOP
FETCH emp_cur INTO emp_rec;
EXIT WHEN emp_cur%NOTFOUND;
Emp_tab (emp_cur%rowcount) := emp_rec;
END LOOP;
Printemployeesdetails(emp_tab);
END;
SELECT empno,ename,job,mgr,hiredate,sal,comm,deptno
FROM scott.emp;
emp_rec emp_cur%ROWTYPE;
TYPE emp_type
IS TABLE OF emp_cur%ROWTYPE INDEX BY BINARY_INTEGER;
emp_tab EMP_TYPE;
counter INTEGER := 0;
PROCEDURE Printemployeesdetails(emp_row EMP_TYPE)
IS
BEGIN
FOR i IN emp_row.first..emp_row.last LOOP
dbms_output.Put_line(Emp_row(i).empno|| ' - '|| Emp_row(i).ename|| ' - '|| Emp_row(i).job|| ' - '|| Emp_row(i).mgr|| ' - '|| Emp_row(i).hiredate|| ' - '|| Emp_row(i).sal|| ' - '|| Emp_row(i).comm|| ' - '|| Emp_row(i).deptno);
END LOOP;
END;
BEGIN
OPEN emp_cur;
LOOP
FETCH emp_cur INTO emp_rec;
EXIT WHEN emp_cur%NOTFOUND;
Emp_tab (emp_cur%rowcount) := emp_rec;
END LOOP;
Printemployeesdetails(emp_tab);
END;
No comments:
Post a Comment