慕粉1024347017
2017-05-05 09:29
包头:
create or replace package pack_test1 is
type userClass is ref cursor;
procedure pro_test1(pkCorp in varchar2,userList out userClass);
end pack_test1;
包体:
create or replace package body pack_test1 is
-- Function and procedure implementations
procedure pro_test1(pkCorp in varchar2,userList out userClass) is
begin
open userList for SELECT * FROM rp_user where corpcode in pkCorp;
end;
end pack_test1;
Java代码:
DBConnection DBConn = new DBConnection();
Connection Conn = DBConn.getConn();
ResultSet rs = null;
String sql = "call pack_test1.pro_test1(?,?)";
CallableStatement call = Conn.prepareCall(sql);
//输入参数赋值
call.setString(1, pk_corps);
//申明输出参数
call.registerOutParameter(2, OracleTypes.CURSOR);
//执行
call.execute();
//取出结果
rs = ((oracle.jdbc.OracleCallableStatement)call).getCursor(2);
while(rs.next()){
UserVo userVo = new UserVo();
userVo.setUnitname(rs.getString("username"));
userVo.setRealname(rs.getString("realname"));
list.add(userVo);
}
不报错,但是结果集没有数据,我确定我表里面是有数据的,麻烦老师帮我看看吧,哪里出错了呀!
call.setString(1, pk_corps); 后面的应该显示的写出pk_corps有哪些吧 没看见你pk_corps这个变量 声明了么?
Oracle存储过程和自定义函数
56308 学习 · 118 问题
相似问题