读书人

Oracle存储过程中执行查询的有关问题

发布时间: 2013-03-26 21:09:10 作者: rapoo

Oracle存储过程中执行查询的问题

SQL code
create or replace procedure getemps( p_cursor in out types.cursorType ) as begin open p_cursor for select * from PROVINCE_MASTER; end; 


这个存储过程怎么执行?

Oracle存储过程中执行查询,如何返回数据集,这样的存储过程该怎么写呢,请高手指教

[解决办法]
declare

cc types.cursorType;
begin
getemps(cc);
end;
[解决办法]
create or replace procedure test_cursor(out_cursor out SYS_REFCURSOR)
is
begin
open out_cursor for
select t.* from emp t;
end;


[解决办法]
探讨
create or replace procedure test_cursor(out_cursor out SYS_REFCURSOR)
is
begin
    open  out_cursor for
    select t.* from emp t;
end;



[解决办法]
SYS_REFCURSOR是Oracle以预先定义的游标,一般来作Out参数进行传递
[解决办法]
探讨
create or replace procedure test_cursor(out_cursor out SYS_REFCURSOR)
is
begin
    open  out_cursor for
    select t.* from emp t;
end;


[解决办法]
在ORACLE中基本存储过程是不能返回数据集的,如果非要返回数据集,可以采取这样的方案,先定义一个包,在,在包里定义一个游标类型,然后同时定义一个函数,返回类型为定义的游标,这样就可以使这个函数返回数据集了。
[解决办法]
study~
[解决办法]
探讨
引用:
create or replace procedure test_cursor(out_cursor out SYS_REFCURSOR)
is
begin
    open  out_cursor for
    select t.* from emp t;
end;



除了使用test跟踪外
使用
declare
cc sys_refcursor;
begin
    test_cursor(cc);
end;
如何能看到返回的结果集

读书人网 >oracle

热点推荐