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能实现吗?

解决方案 »

  1.   

    在sqlplus中,你可以 print mytest.GetMSG( 2485 );
      

  2.   

    在包体当中,定义全局FUNCTION GetMSG的时候,可以使用游标来输出结果集
      

  3.   

    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;这个是我在公司培训时做的一个过程示例,你可以利用一下,不知道对你的问题理解的对不对。
      

  4.   

    其实我已经用其他办法实现了GetMSG的功能,就是麻烦一些,想看看有没有更好的解决办法。
    谢谢诸位的回答。