--包
create or replace package p1
as
  type mycousor is ref cursor;
  procedure myprocedure(qq out mycursor);
end;
--包体
create or replace package body package p1
is
  procedure myprocedure(qq out mycursor)
  as
  begin
  open qq for select tid,tname from temp;
  end;
end;
--调用
declare 
  q mycursor;
  qqq temp%rowtype;
begin 
  p1.myprocedure(q);
  loop
  fetch q into qqq;
  exit when q%notfound;
  dbms_output.put_line(qqq.tid);
  dbms_output.put_line(qqq.tname);
  end loop;
  close qq;
end;以上代码在运行时候出现了错误,我本是想通过这段代码来得到一个结果集。各位,怎么改动?

解决方案 »

  1.   

    declare 
      q p1.mycursor; 
      qqq temp%rowtype; 
    begin 
      p1.myprocedure(q); 
      loop 
      fetch q into qqq; 
      exit when q%notfound; 
      dbms_output.put_line(qqq.tid); 
      dbms_output.put_line(qqq.tname); 
      end loop; 
      close qq; 
    end;包编译应该没问题,调用的时候类型声明该出错了
      

  2.   

    close qq; -》
    close q;
      

  3.   

    恩 楼主按shiyiwan说的改改试试看行不行
      

  4.   

    还有一个地方,包体里多了一个package