--游标作为一个类型共用
create package pack1 is
type my_cursor is ref cursor;
end;
--输出游标为了程序后续使用,此游标打印所有输入表名的所有内容
create or replace procedure showall(v_table varchar2,v_out_result out pack1.my_cursor) is
beginopen v_out_result for ' select * from '||v_table;
end showall;
--测试过程:
v_table varchar2(20):='userTable';
v_out pack1.my_cursor;
tt usertable%rowtype;
begin
showall(v_table,v_out_result =>v_out );
loop
fetch v_out into tt;
dbms_output.put_line(tt.userid||tt.username);
exit when v_out %notfound;
end loop;
close v_out;
end;