如何执行Oracle中的存储过程?急

ITMiner 2008-10-26 09:42:34
我在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;

请问下我应该怎样执行这个过程啊?才能返回一个结果集呢?谢谢各位大侠!
...全文
5559 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ITMiner 2008-10-27
  • 打赏
  • 举报
回复
谢谢兄弟!
vc555 2008-10-26
  • 打赏
  • 举报
回复
其实LZ用的是10g,就没必要先去定义一个TYPE了。
给你个例子:
OPER@TL>select select * from test;

AAA BBB
---------- ----------
1 1
2 2
3 3
3 10

OPER@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 refcursor
OPER@TL>exec test_p(3,:abc)

PL/SQL procedure successfully completed.

OPER@TL>print :abc

AAA BBB
---------- ----------
3 3
3 10

OPER@TL>

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧