有没有办法做这样的事情?将游标获取的数据输出到引用游标中而不先将其填充到表中?
create or replace procedure someprocedure
(
rc1 in out adv_refcur_pkg.rc) -- this is defined below
as
v_class_year varchar(10);
cursor c1
is
select distinct e.pref_class_year
from entity e
where e.pref_class_year between i_start_class and i_end_class;
begin
open c1;
loop
fetch c1 into v_class_year;
EXIT WHEN c1%NOTFOUND;
end loop;
close c1;
open rc1 for select v_class_year from dual;
end;
这是 refcursor 的声明
CREATE OR REPLACE PACKAGE ADVANCE.adv_refcur_pkg
AS
TYPE RC IS REF CURSOR;
END adv_refcur_pkg;