ref cursor问题求助

blt 2009-08-01 09:58:31
create or replace package mytest is

type T_CURSOR is REF CURSOR;

-- Public function and procedure declarations
FUNCTION GetMSG( id IN NUMBER ) RETURN T_CURSOR;

执行 SELECT mytest.GetMSG( 2485 ) FROM dual 后,取出的是ref cursor。但我想把ref cursor中的内容取出来?用select能实现吗?
...全文
45 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
blt 2009-08-02
  • 打赏
  • 举报
回复
1、由于种种原因,我在程序中无法使用游标。
2、我面对的是海量数据,所以无法用4楼的方法。
blt 2009-08-02
  • 打赏
  • 举报
回复
其实我已经用其他办法实现了GetMSG的功能,就是麻烦一些,想看看有没有更好的解决办法。
谢谢诸位的回答。
inthirties 2009-08-02
  • 打赏
  • 举报
回复
如果是这样考虑一下分批提交的方式。
zhangchu_63 2009-08-01
  • 打赏
  • 举报
回复
create or replace procedure test_inout(result out varchar2) is
----------------------------------------------------------------
--参数类型为OUT的存储过程
----------------------------------------------------------------
cursor c is select * from t_employee t where t.depart_id='001';

begin

/**
*用循环把查出来的数据拼接起来
*/
for c_result in c loop
result := result||c_result.e_name;
end loop;

dbms_output.put_line('result='||result);

/**
*异常处理
*/
exception
when others then
dbms_output.put_line('there is no data !!');

end test_inout;

这个是我在公司培训时做的一个过程示例,你可以利用一下,不知道对你的问题理解的对不对。
csuxp2008 2009-08-01
  • 打赏
  • 举报
回复
在包体当中,定义全局FUNCTION GetMSG的时候,可以使用游标来输出结果集
majy 2009-08-01
  • 打赏
  • 举报
回复
在sqlplus中,你可以 print mytest.GetMSG( 2485 );
inthirties 2009-08-01
  • 打赏
  • 举报
回复
select不行,可以循环游标

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧