我在oracle10g中的scott方案中创建了一下一个包和过程:
create or replace package testpackage
as
type test_cursor is ref cursor;
end testpackage;
create or replace procedure P_STSCORE
(deptno in int,p_cursor out testpackage.test_cursor) is
begin
open p_cursor for select * from dept where deptno=deptno;
end p_stscore;
请问下我应该怎样执行这个过程啊?才能返回一个结果集呢?谢谢各位大侠!
------解决方案--------------------
代码迷推荐解决方案:oracle存储过程,http://www.daimami.com/search?q=177537
------解决方案--------------------
其实LZ用的是10g,就没必要先去定义一个TYPE了。
给你个例子:
- SQL code
OPER@TL>select select * from test; AAA BBB---------- ---------- 1 1 2 2 3 3 3 10OPER@TL>create or replace procedure test_p(in_var number,out_var out sys_refcursor) 2 as 3 begin 4 open out_var for select * from test where aaa=in_var; 5 end; 6 /Procedure created.OPER@TL>var abc refcursorOPER@TL>exec test_p(3,:abc)PL/SQL procedure successfully completed.OPER@TL>print :abc AAA BBB---------- ---------- 3 3 3 10OPER@TL>