首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

怎么执行Oracle中的存储过程?

2013-03-26 
如何执行Oracle中的存储过程?急我在oracle10g中的scott方案中创建了一下一个包和过程:create or replace p

如何执行Oracle中的存储过程?急
我在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.myexception.cn/oracle-develop/177537.html
[解决办法]
其实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> 

热点排行
Bad Request.