标题: 如何在oracle存储过程中返回游标
ljjk5
元帅
Rank: 1


荣誉会员奖章
UID 46706
精华 1
积分 99426
帖子 49690
威望 554
金币 48489
热心 505
阅读权限 100
注册 2007-2-25
状态 离线
如何在oracle存储过程中返回游标

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()){......}
baidu

网友 ljjk5 签名 - 网友社区 ===
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-10-12 12:26
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP