Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->数据库应用 ->Oracle ->正文

如何在oracle存储过程中返回游标

来源:Linuxdby.com 作者:Webmaster 时间:2007-06-03 点击: [收藏] [投稿]

1:首先你需要创建一个包,并定义你返回的游标的类型、存储过程

create or replace package TEST_PKG is
 
  -- Public type declarations
  type cur_emp is REF CURSOR;
 
  procedure test_proc (v_empno in number, emps out cur_emp);
 
end TEST_PKG;

2:然后你再创建包体

create or replace package body TEST_PKG is

procedure test_proc (v_empno in number, emps out cur_emp)
as
begin
open emps for select * from emp where empno=7369;
end test_proc; 
end TEST_PKG ;

3,通过JAVA调用

cstmt = conn.prepareCall("{call TEST_PKG .test_proc (?)}");
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.execute();
 
//获得结果集
rs = (ResultSet)cstmt.getObject(4);
while(rs.next()){......}



 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:Oracle 10g + SQL SERVER 2000 透明网关设置   下一篇:oracle 10g 安装中一些问题解决

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号