日期:2014-05-17  浏览次数:21025 次

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
)
is
begin
    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窗口调用此存储过程?
并:
……