--临时表语法
--会话型的,会话结束数据清空
create global temporary table test_tmp(id number,name varchar2(10).....)
on commit preserve rows
--事务型的,事务结束数据清空
create global temporary table test_tmp(id number,name varchar2(10)......)
on commit delete rows
--过程
create or replace procedure p_rec(cur out sys_refcursor)
as
begin
insert into 临时表 select * from tb;
commit;
open cur for select * from 临时表 where ....;
end;
--调用
var cur refcursor
exec p_rec(:cur);
print cur
或者
declare
cur sys_refcursor;
变量...;
begin
fetch cur into 变量;
while cur%found loop
dbms_output.put_line(变量);
fetch cur into 变量;
end loop;
close cur;
end;