Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as ttgoldc
SQL> set serveroutput on
SQL>
SQL> DECLARE
2 TYPE emp_cur_type IS REF CURSOR;
3 TYPE dept_cur_type IS REF CURSOR;
4 v_ename SCOTT.emp.ename%TYPE;
5 v_dname SCOTT.dept.dname%TYPE;
6 emp_cur emp_cur_type;
7 dept_cur dept_cur_type;
8 BEGIN
9 OPEN dept_cur FOR
10 SELECT d.dname,
11 CURSOR (SELECT e.ename
12 FROM SCOTT.emp e
13 WHERE e.deptno = d.deptno) emps
14 FROM SCOTT.dept d;
15 LOOP
16 FETCH dept_cur
17 INTO v_dname,
18 emp_cur;
19 EXIT WHEN dept_cur%NOTFOUND;
20 dbms_output.put_line('dname is : ' || v_dname);
21 LOOP
22 FETCH emp_cur
23 INTO v_ename;
24 EXIT WHEN emp_cur%NOTFOUND;
25 dbms_output.put_line('--ename is : ' || v_ename);
26 END LOOP;
27 END LOOP;
28 CLOSE dept_cur;
29
30 IF emp_cur%ISOPEN THEN
31 dbms_output.put_line('emp_cur is open');
32 ELSE
33 dbms_output.put_line('emp_cur not open');
34 END IF;
35 END;
36 /
dname is : ACCOUNTING
--ename is : CLARK
--ename is : KING
--ename is : MILLER
dname is : RESEARCH
--ename is : SMITH
--ename is : JONES
--ename is : SCOTT
--ename is : ADAMS
--ename is : FORD
dname is : SALES
--ename is : ALLEN
--ename is : WARD
--ename is : MARTIN
--ename is : BLAKE
--ename is : TURNER
--ename is : JAMES
dname is : OPERATIONS
emp_cur not open
PL/SQL procedure successfully completed
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as ttgoldc
SQL> set serveroutput on
SQL>
SQL> DECLARE
2 TYPE emp_cur_type IS REF CURSOR;
3 TYPE dept_cur_type IS REF CURSOR;
4 v_ename SCOTT.emp.ename%TYPE;
5 v_dname SCOTT.dept.dname%TYPE;
6 emp_cur emp_cur_type;
7 dept_cur dept_cur_type;
8 BEGIN
9 OPEN dept_cur FOR
10 SELECT d.dname,
11 CURSOR (SELECT e.ename
12 FROM SCOTT.emp e
13 WHERE e.deptno = d.deptno) emps
14 FROM SCOTT.dept d;
15 LOOP
16 FETCH dept_cur
17 INTO v_dname,
18 emp_cur;
19 EXIT WHEN dept_cur%NOTFOUND;
20 dbms_output.put_line('dname is : ' || v_dname);
21 LOOP
22 FETCH emp_cur
23 INTO v_ename;
24 EXIT WHEN emp_cur%NOTFOUND;
25 dbms_output.put_line('--ename is : ' || v_ename);
26 END LOOP;
27 END LOOP;
28 CLOSE dept_cur;
29
30 IF emp_cur%ISOPEN THEN
31 dbms_output.put_line('emp_cur is open');
32 ELSE
33 dbms_output.put_line('emp_cur not open');
34 END IF;
35 END;
36 /
dname is : ACCOUNTING
--ename is : CLARK
--ename is : KING
--ename is : MILLER
dname is : RESEARCH
--ename is : SMITH
--ename is : JONES
--ename is : SCOTT
--ename is : ADAMS
--ename is : FORD
dname is : SALES
--ename is : ALLEN
--ename is : WARD
--ename is : MARTIN
--ename is : BLAKE
--ename is : TURNER
--ename is : JAMES
dname is : OPERATIONS
emp_cur not open
PL/SQL procedure successfully completed
SQL>
whenever, show us your environment and so on ...