请高手指教: pl/sql中 一个存储过程返回游标,另一个存储过程调用那个过程获得游标并赋值个游标变量例如:
create or replace procedure pro_AAA ---是否可以这样返回游标???????
(
aid number,
cur_X out sys_recursor
)as
type mytype is ref cursor;
cur_Y mytype;
begin
open cur_Y for select * from table_Name;
cur_X:=cur_Y;
end pro_AAA;create or replace procedure pro_BBB
(
cur_X out sys_recursor
)as
type mytype is ref cursor;
cur_B mytype;
begin
cur_B:= 调用pro_AAA(...) 这里怎么办????
end pro_BBB;
create or replace procedure pro_AAA ---是否可以这样返回游标???????
(
aid number,
cur_X out sys_recursor
)as
type mytype is ref cursor;
cur_Y mytype;
begin
open cur_Y for select * from table_Name;
cur_X:=cur_Y;
end pro_AAA;create or replace procedure pro_BBB
(
cur_X out sys_recursor
)as
type mytype is ref cursor;
cur_B mytype;
begin
cur_B:= 调用pro_AAA(...) 这里怎么办????
end pro_BBB;
解决方案 »
- 求一个统计报表怎么实现,可以用oracle过程实现
- oracle数据库可以登录的上。在myeclipse中连接数据库时就一直报the network adapter could not establish con
- ERwin 模型在复制表或保存变很慢
- 分区表索引建立问题
- 模糊查询优化
- 急!急!!急!!!ORACLE中的表怎么导出来??????????
- 请教教我ORACLE.一点也不会啊.急啊
- 高分求救,一个高难度的SQL语句??
- 请大家推荐几本学习oracle的好书
- 请问在oracle存储过程里怎样实现for/while/loop循环和动态执行sql?
- 求教一条sql,类似聚合查询
- 函数,存储过程
(
aid number,
cur_X out sys_recursor
)as
type mytype is ref cursor;
cur_Y mytype;
begin
open cur_Y for select * from table_Name;
cur_X:=cur_Y;
end pro_AAA; create or replace procedure pro_BBB
(
cur_X out sys_recursor
)as
type mytype is ref cursor;
cur_B mytype;
begin
--cur_B:= 调用pro_AAA(...) 这里怎么办????
PRO_AAA(V_AID, CUR_B); --这里接收游标
FOR X IN CUR_B LOOP
NULL; --这里对接收到的游标循环处理。
END LOOP;
/
end pro_BBB;
因为你用游标的目的是为了传输结果集
这种不同存储过程之间,你用游标还不如单独建一张表
一个存储过程生成结果到这张表,另外调用的存储过程从这张表里取数据
delcare
v_aa varchar2(10);--这个和table表中aa类型大小一样
cursor v_cur is select aa from table;
begin
open v_cur; --打开游标
fetch v_cur into v_aa; --取出第一条记录存入变量
while v_cur %found loop --循环判断,取数为空时退出
--对值进行处理
fetch v_cur into v_aa; --取下一条
end loop;
close v_cur; --关闭游标
end;
create or replace procedure pro_AAA(
aid number,
cur_X out sys_recursor --输出游标参数
)as
begin
open cur_X for select * from table_Name; --游标
end pro_AAA; create or replace procedure pro_BBB
(
)as
cur_B SYS_REFCURSOR;
begin
PRO_AAA(CUR_B); --这里接收游标
FOR X IN CUR_B LOOP
NULL; --这里对接收到的游标循环处理。
END LOOP;
/
end pro_BBB;