CREATE OR REPLACE PACKAGE pkg_test
AS
TYPE myrctype IS REF CURSOR;
END pkg_test;
/create PROCEDURE get(p_age NUMBER, p_rc OUT pkg_test.myrctype)
IS
sqlstr VARCHAR2 (500);
BEGIN
sqlstr:='select id,name,sex,address,postcode,birthday
from student where age='||p_age;
OPEN p_rc FOR sqlstr;
END get;
AS
TYPE myrctype IS REF CURSOR;
END pkg_test;
/create PROCEDURE get(p_age NUMBER, p_rc OUT pkg_test.myrctype)
IS
sqlstr VARCHAR2 (500);
BEGIN
sqlstr:='select id,name,sex,address,postcode,birthday
from student where age='||p_age;
OPEN p_rc FOR sqlstr;
END get;
w_rc pkg_test.myrctype;
w_id student.id%type;
w_name student.name%type;
w_sex student.sex%type;
w_address student.address%type;
w_postcode student.postcode%type;
w_birthday student.birthday%type;
begin
get('1',w_rc);
loop
fetch w_rc into w_id,w_name,w_sex,w_address,w_postcode,w_birthday;
exit when w_rc%notfound;
dbms_output.put_line(w_name);
end loop;
end;
/