views:

52

answers:

1

I am debugging an issue with a null ResultsMap returned from calling a stored procedure via iBatis for java. Here is a truncated copy of the exception I'm receiving.

DataAccessException: Exception calling procedure
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: 
--- The error occurred in ibatis-map.xml.  
--- The error occurred while applying a parameter map.  
--- Check the getEmpLoanDistribContribInfoMap.  
--- Check the output parameters (retrieval of output parameters failed).  
--- Cause: java.sql.SQLException: Cursor is closed.

I don't believe the problem is actually in the parameter map, since similar code works in other areas of the project, but I have included the parameter map and the stored proc header here just in case.

<parameterMap id="getEmpLoanDistribContribInfoMap" class="map" >
    <parameter property="resultCode" javaType="int" jdbcType="NUMERIC" nullValue="-1" mode="OUT"/>
    <parameter property="client_id" javaType="int" jdbcType="NUMERIC" mode="IN"/>
    <parameter property="emp_nbr" javaType="int" jdbcType="NUMERIC" mode="IN"/>
    <parameter property="general_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
    <parameter property="current_contrib_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
    <parameter property="future_contrib_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
    <parameter property="distrib_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
    <parameter property="loan_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
</parameterMap>

function get_emp_ldc_info (
  client_id                 employees.clt_id%type,
  emp_nbr                   employees.emp_nbr%type,
  general_info              out retire_ref_types.retire_ref_cursor,
  current_contrib_info      out retire_ref_types.retire_ref_cursor,
  future_contrib_info       out retire_ref_types.retire_ref_cursor,
  distrib_info              out retire_ref_types.retire_ref_cursor,
  loan_info                 out retire_ref_types.retire_ref_cursor
) return number is
  retval number;

Each of the 5 cursors above are opened for selects within the body of the function. I extracted each select query, and all of them run properly (though some don't find any records -- could this be my problem?). I even created a script mirroring this function that defines each cursor in a declare block, and opens them. No exceptions are encountered.

I realize my problem could very well be bad data, but I am not sure where to look. The only thing I can think of is that I should be getting this exception if one of the out cursors in the parameter map is opened for a select that finds no data. Does anyone know if this is true?

A: 

I have confirmed that it was bad data causing this. I still haven't found where it is, but I'm answering the question so nobody wastes their time on this. Thanks for reading.

dpatch