Java調(diào)用存儲過程結(jié)果集為空
包頭:
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);
//輸入?yún)?shù)賦值
call.setString(1, pk_corps);
//申明輸出參數(shù)
call.registerOutParameter(2, OracleTypes.CURSOR);
//執(zhí)行
call.execute();
//取出結(jié)果
? 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);
}
不報錯,但是結(jié)果集沒有數(shù)據(jù),我確定我表里面是有數(shù)據(jù)的,麻煩老師幫我看看吧,哪里出錯了呀!
2017-05-08
call.setString(1, pk_corps); 后面的應該顯示的寫出pk_corps有哪些吧 ?沒看見你pk_corps這個變量 ? 聲明了么?