--游标类型传入参数
DECLARE
/*CURSOR cur_ttt IS
SELECT 1 a FROM dual;*/
TYPE typ_cur IS REF CURSOR;
val_cur typ_cur;
PROCEDURE temp_sp1(x_cur OUT typ_cur) IS
BEGIN
OPEN x_cur FOR SELECT 1 a FROM dual UNION ALL SELECT 2 FROM dual;
END;
PROCEDURE temp_sp2(p_cur IN typ_cur) IS
i NUMBER;
BEGIN
LOOP
FETCH p_cur INTO i;
EXIT WHEN p_cur%NOTFOUND;
dbms_output.put_line(i);
END LOOP;
CLOSE p_cur;
END;
BEGIN
temp_sp1(val_cur);
temp_sp2(val_cur);
OPEN val_cur FOR SELECT 3 a FROM dual UNION ALL SELECT 4 FROM dual;
temp_sp2(val_cur);
END;
SELECT t.id,
b.rn,
decode(b.rn,
1,
t.scat_int,
2,
t.incl_int,
3,
t.other_int,
4,
t.rc_int) AS INT,
t.seq_no
FROM test_3_6 t, (SELECT rownum rn FROM dual CONNECT BY rownum <= 4) b
WHERE t.id = 1
AND decode(b.rn,
1,
t.scat_int,
2,
t.incl_int,
3,
t.other_int,
4,
t.rc_int) IS NOT NULL
DECLARE
/*CURSOR cur_ttt IS
SELECT 1 a FROM dual;*/
TYPE typ_cur IS REF CURSOR;
val_cur typ_cur;
PROCEDURE temp_sp1(x_cur OUT typ_cur) IS
BEGIN
OPEN x_cur FOR SELECT 1 a FROM dual UNION ALL SELECT 2 FROM dual;
END;
PROCEDURE temp_sp2(p_cur IN typ_cur) IS
i NUMBER;
BEGIN
LOOP
FETCH p_cur INTO i;
EXIT WHEN p_cur%NOTFOUND;
dbms_output.put_line(i);
END LOOP;
CLOSE p_cur;
END;
BEGIN
temp_sp1(val_cur);
temp_sp2(val_cur);
OPEN val_cur FOR SELECT 3 a FROM dual UNION ALL SELECT 4 FROM dual;
temp_sp2(val_cur);
END;
SELECT t.id,
b.rn,
decode(b.rn,
1,
t.scat_int,
2,
t.incl_int,
3,
t.other_int,
4,
t.rc_int) AS INT,
t.seq_no
FROM test_3_6 t, (SELECT rownum rn FROM dual CONNECT BY rownum <= 4) b
WHERE t.id = 1
AND decode(b.rn,
1,
t.scat_int,
2,
t.incl_int,
3,
t.other_int,
4,
t.rc_int) IS NOT NULL