create or replace package my_package
is
man_num number;
woman_num number;
type person is ref cursor;end my_package;
/create package body my_package
as
cursor person(这是游标的名字与定义的游标类型没有关系) is
select no,name from persons
where no<99001;
begin
for aa in person loop
循环操作游标数据
.....
end loop
end my_package;
type person is ref cursor;
这个的用法
在包体中使用,例如
procedure aa(rs out person)---这个person是在包头中定义的那个person(游标类型)
as
begin
open rs for 'select * froma';
end aa;
is
man_num number;
woman_num number;
type person is ref cursor;end my_package;
/create package body my_package
as
cursor person(这是游标的名字与定义的游标类型没有关系) is
select no,name from persons
where no<99001;
begin
for aa in person loop
循环操作游标数据
.....
end loop
end my_package;
type person is ref cursor;
这个的用法
在包体中使用,例如
procedure aa(rs out person)---这个person是在包头中定义的那个person(游标类型)
as
begin
open rs for 'select * froma';
end aa;
as
v_no persons.no%type;
v_name persons.name%type;cursor person is
select no,name from persons
where no<99001;open person;
loop
fetch person into v_no,v_name;
exit when person%NOTFOUND;
--要处理的内容
end loop;
close person;
end my_package;
--包头声明
create or replace package my_package
is
man_num number;
woman_num number;
end my_package;
/
--包体
create or replace package body my_package
is
cursor mycursor is select * from persons;
end my_package;
/
第2种在包头中声明游标
--包头声明
create or replace package my_package
is
man_num number;
woman_num number;
cursor mycursor return persons%rowtype;
end my_package;
/
--包体
create or replace package body my_package
is
cursor mycursor return persons%rowtype is select * from persons;
end my_package;
/
共同学习哈