当前位置: 代码迷 >> Oracle管理 >> pl/sql怎么调用带有游标的存储过程(sql窗口的调用)
  详细解决方案

pl/sql怎么调用带有游标的存储过程(sql窗口的调用)

热度:95   发布时间:2016-04-24 05:11:04.0
pl/sql如何调用带有游标的存储过程(sql窗口的调用)
以下是我创建的存储过程:
create or replace procedure countinfo
(sno in char,out_val out sys_refcursor)
as
begin
open out_val for select * from countinfo
where s_no=sno;
end;
/
请问如何用sql窗口调用此存储过程?
并:
  这样可以实现返回多个数据集吗?

------解决方案--------------------
可以,给你个例子
SQL code
--创建与你类似的游标create or replace procedure deptp(deptno int,out_deptlist out sys_refcursor)isbegin    open out_deptlist for select * from dept where deptno>1;end;/--调用,懒得写了,和正常的游标一样调用declare     deptno int := 0;    deptlist sys_refcursor;begin    deptp(deptno,deptlist);    if deptlist%isopen then        --此处像正常游标一样调用就可以了        dbms_output.put_line('deptlist opened');        close deptlist;    end if;end;/
------解决方案--------------------
一样的调用方法,直接使用Out参数返回的游标。
------解决方案--------------------
探讨
以下是我创建的存储过程:
create or replace procedure countinfo
(sno in char,out_val out sys_refcursor)
as
begin
open out_val for select * from countinfo
where s_no=sno;
end;
/
请问如何用sql窗口调用此存储过程?
并:
……

------解决方案--------------------
探讨
以下是我创建的存储过程:
create or replace procedure countinfo
(sno in char,out_val out sys_refcursor)
as
begin
open out_val for select * from countinfo
where s_no=sno;
end;
/
请问如何用sql窗口调用此存储过程?
并:
……
  相关解决方案