geschachtelte Cursor (Lange Version)
Tipp 72
Thema: Cursor
Datenbank-Version: RDBMS 8.x
Erstellt am 07.10.19
Bearbeitet am 07.10.19
DECLARE
CURSOR cur_emp (p_deptno IN NUMBER) IS SELECT *
FROM scott.emp
WHERE deptno=p_deptno;
CURSOR cur_dept IS SELECT *
FROM scott.dept;
BEGIN
FOR dept_satz IN cur_dept LOOP
dbms_output.put_line('Mitarbeiter in Abteilung:'||dept_satz.dname||' Nr.:'||dept_satz.deptno);
FOR emp_satz IN cur_emp(dept_satz.deptno) LOOP -- Hier wird die Abt-Nr eingesetzt (10,20,30,40)
dbms_output.put_line(' Mitarbeiter: '||emp_satz.ename);
END LOOP;
END LOOP;
END;
/