Cursor 作為引數傳遞並返回結果

season0891發表於2008-08-14
create or repalce package empdata as

cursor cur1 is select * from tabs;

type empcur is ref cursor return cur1%rowtype;

peocedure getempDate(myempcur in out empcur);

end empdata;


create or replace package body empdata as

procedure getempdata(myempcur in out empcur)

is

begin

 open myempcur for
   select * from tabs;

end getempdata;

end empdata;



解決辦法如下 :

declare curs empdata.cur1%rowtype;

begin

IF empdata.cur1%ISOPEN THEN

CLOSE empdata.cur1;

END IF;

open empdata.cur1;

 loop
   fetch empdata.cur1 into curs;
   exit when empdata.cur1%ROWCOUNT>10;
   dbms_output.put_line(curs.TABLE_NAME);
 end loop;
 close empdata.cur1;

end;

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90618/viewspace-426897/,如需轉載,請註明出處,否則將追究法律責任。

相關文章