求助调用存储过程出来 Cursor is closed 问题
我想在存储过程中返回一个游标,可是在后台程序中调用这个存储过程就出现 Cursor is closed 这个错误~请兄弟们帮忙解决。
存储过程:
create or replace procedure SP_A_SUPPLIER_EVAL(IN_SUPPLIER_ID IN NUMBER, /*-------供应商ID-------*/
IN_EQUIP_CATEG IN VARCHAR2, /*-------类别标识-------*/
O_EVAL_SCORE OUT NUMBER, /*-------评分-------*/
O_EVAL_RESLUT OUT SYS_REFCURSOR, /*-------返回结果集-------*/
O_EXCEPTION_FALG OUT NUMBER, /*-------异常标识-------*/
O_EXCEPTION_MSG OUT VARCHAR2 /*-------异常信息-------*/) is
...
OPEN O_EVAL_RESLUT FOR SELECT V_SUPPLIER_SCORE AS SUPPLIER_SCORE, V_CONTRACT_SCORE AS CONTRACT_SCORE, V_SERVICE_RESPONSE_SCORE AS SERVICE_RESPONSE_SCORE, V_BUSINESS_TREAT_SCORE ASBUSINESS_TREAT_SCORE
, V_ARRIVE_UNSUFFICE_SCORE AS ARRIVE_UNSUFFICE_SCORE
,V_DAY_PICK_SUCCESS_SCORE AS DAY_PICK_SUCCESS_SCORE, V_QUALITY_EVALUATE_SCORE AS QUALITY_EVALUATE_SCORE,V_QUALITY AS QUALITY, V_SERVICE AS SERVICE, V_SUPPLIER AS SUPPLIER FROM DUAL;
...
end SP_A_SUPPLIER_EVAL;
java代码:
Connection con = this.jdbcHandle.getDataSource().getConnection();
CallableStatement cs = con.prepareCall("{call SP_A_SUPPLIER_EVAL(?,?,?,?,?,?)}");
cs.setLong(1, supplierId);
cs.setString(2, equipCateg);
cs.registerOutParameter(3, Type.DOUBLE);
//OracleTypes.CURSOR 的值为:-10
cs.registerOutParameter(4, -10);
cs.registerOutParameter(5, Types.INTEGER);
cs.registerOutParameter(6, Types.VARCHAR);
boolean isExc = cs.execute();
if(!isExc){
supplierEvalBo.setScore(cs.getDouble(3));
ResultSet rs = (ResultSet) cs.getObject(4);
if(rs.next()){
....
}
}
在红色字部分就报错了,这是为什么呢?
我在测试存储过程中,游标结果集里面是有记录的,我在dbms_output.put_line(O_EVAL_RESLUT%ROWCOUNT);输出行数的时候结果是0这是为什么呢?
[解决办法]
里面的游标,O_EVAL_RESLUT是有记录的吗?
SELECT V_SUPPLIER_SCORE AS SUPPLIER_SCORE, V_CONTRACT_SCORE AS CONTRACT_SCORE, V_SERVICE_RESPONSE_SCORE AS SERVICE_RESPONSE_SCORE, V_BUSINESS_TREAT_SCORE ASBUSINESS_TREAT_SCORE
, V_ARRIVE_UNSUFFICE_SCORE AS ARRIVE_UNSUFFICE_SCORE
,V_DAY_PICK_SUCCESS_SCORE AS DAY_PICK_SUCCESS_SCORE, V_QUALITY_EVALUATE_SCORE AS QUALITY_EVALUATE_SCORE,V_QUALITY AS QUALITY, V_SERVICE AS SERVICE, V_SUPPLIER AS SUPPLIER FROM DUAL;
这一段sql查的是什么?V_SUPPLIER_SCORE,V_CONTRACT_SCORE...这些都是什么?是定义的变量吗?看楼主是从dual表里查的。