在sql server中如果要在一存储过程中得到另一存储过程的返回结果集,只需要在存储过程中这样写 如:INSERT #Goods_Level EXEC P_BUILD_LEVEL @aspID=@vcAspID;
但是在oracle中怎样获取呢?

解决方案 »

  1.   

    create table t1(cid int,cname varchar2(100));
    insert into t1 values( 1,'3' );
    insert into t1 values( 2,'4' );
    /
    ----创建包
    create or replace package aaa
    is
    type cur is ref cursor;
    procedure bbb(rst out cur );
    procedure ccc;
    end;
    /
    --创建包体
    create or replace package body aaa
    is
    procedure bbb(rst out cur )
    is
    begin
      open rst for select * from t1;
    end;
    procedure ccc
    is
    FRst cur;
    cid int;
    cname varchar2(100);
    begin
      bbb(FRst);
      loop
      fetch FRst into cid,cname;
      exit when FRst%notfound;
      dbms_output.put_line( cname );
      end loop;
    end;
    end;/
    --测试
    declare
     i int;
    begin
     aaa.ccc;
    end;
    /
    --输出结果
    3
    4
    drop table t1;