看书上写,游标变量不能在包定义,在9i试了试,结果是可以得,
create or replace package Test2Package as
type mycursor is ref cursor; -- 定义游标变量
procedure GetRecords(ret_cursor out mycursor); -- 定义过程,用游标变量作为返回参数
end Test2Package; create or replace package body Test2Package as
/*过程体*/
procedure GetRecords(ret_cursor out mycursor) as
begin
open ret_cursor for select * from wwcm.cm_lookups;
end GetRecords;
end Test2Package;
编译通过,没有错误;
create or replace package Test2Package as
type mycursor is ref cursor; -- 定义游标变量
procedure GetRecords(ret_cursor out mycursor); -- 定义过程,用游标变量作为返回参数
end Test2Package; create or replace package body Test2Package as
/*过程体*/
procedure GetRecords(ret_cursor out mycursor) as
begin
open ret_cursor for select * from wwcm.cm_lookups;
end GetRecords;
end Test2Package;
编译通过,没有错误;
在包头中,先定义一个游标类型即可
type mycursor is ref cursor; -- 定义游标变量 ----这里是定义游标类型不是定义游标变量
c1 mycursor -------这里才是定义游标变量,包将会出错