top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How does one Loop through tables in Oracle PL/SQL

+1 vote
559 views
How does one Loop through tables in Oracle PL/SQL
posted Sep 15, 2014 by Suchithra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

below is the example:

DECLARE
CURSOR dept_cur
IS
SELECT deptno
FROM dept
ORDER BY deptno;
CURSOR emp_cur (v_dept_no DEPT.DEPTNO%TYPE)
IS
SELECT ename
FROM emp
WHERE deptno = v_dept_no;
BEGIN
FOR dept_rec IN dept_cur LOOP
dbms_output.put_line('Employees in Department '||TO_CHAR(dept_rec.deptno));
FOR emp_rec in emp_cur(dept_rec.deptno) LOOP
dbms_output.put_line('...Employee is '||emp_rec.ename);
END LOOP;
END LOOP;
END;

answer Sep 15, 2014 by Arun Gowda
...