1

I am following this link http://docs.spring.io/spring-data/jdbc/docs/1.1.0.RELEASE/reference/html/orcl.datatypes.html#d0e2387

Here is my oracle procedure specifications

CREATE OR REPLACE PACKAGE PKG_RE_FI AS

  PROCEDURE PRC_RE_FI_DETAILS(P_FAN_NO       IN VARCHAR2,
                              P_REF_ID       IN TY_APP_REF_ID,
                              P_COMMENTS     IN VARCHAR2,
                              P_BILLING_FLAG IN VARCHAR2,
                              P_STATUS       OUT VARCHAR2);

END PKG_RE_FI;TY_APP_REF_ID is

    CREATE OR REPLACE TYPE ty_app_REF_ID as varray(500) of obj_array_ref_id

    CREATE OR REPLACE TYPE obj_array_ref_id  AS OBJECT(
    app_ref_id VARCHAR2(100)

)

I am using Spring JDBC Framework(SimpleJdbcCall object) to execute above procedure. Below is the code snippet in which i have declared

this.reFIJdbcCall =  new SimpleJdbcCall(dataSource).withCatalogName("PKG_RE_FI").
                      withProcedureName("PRC_RE_FI_DETAILS").withoutProcedureColumnMetaDataAccess().declareParameters(new SqlParameter("P_FAN_NO", Types.VARCHAR),
                                new SqlParameter("P_REF_ID", OracleTypes.ARRAY, "TY_APP_REF_ID"),
                                new SqlParameter("P_COMMENTS", Types.VARCHAR),
                                new SqlParameter("P_BILLING_FLAG", Types.VARCHAR),
                                new SqlOutParameter("P_STATUS", Types.VARCHAR)
                      );

@Override
public ReFIResponse reInitiateFI(ReFIRequest reFIRequest) {
     MapSqlParameterSource in = new MapSqlParameterSource();
    // Map in = Collections.singletonMap("in_actor_ids", new SqlArrayValue(ids)); 
       in.addValue("P_FAN_NO",reFIRequest.getFanNo());  
       String[] refIDS = new String[reFIRequest.getApplicantReferenceID().size()];
       refIDS = reFIRequest.getApplicantReferenceID().toArray(refIDS);
       in.addValue("P_REF_ID", new SqlArrayValue(refIDS));
       in.addValue("P_COMMENTS", reFIRequest.getComments());
       in.addValue("P_BILLING_FLAG", reFIRequest.getFiBillingFlag());
       Map  result = reFIJdbcCall.execute(in);
       String status = (String)result.get("P_STATUS");

    return null;
}

I get the Following Error

Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call PKG_RE_FI.PRC_RE_FI_DETAILS(?, ?, ?, ?, ?)}]; SQL state [null]; error code [17059]; Fail to convert to internal representation: TMFI10000031A; nested exception is java.sql.SQLException: Fail to convert to internal representation: TMFI10000031A
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
    at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
    at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
    at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
    at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:181)
    at com.tcs.fi.dao.ReFIDAOImpl.reInitiateFI(ReFIDAOImpl.java:77)
    at com.tcs.fi.business.FIReInitiator.reInitiateFI(FIReInitiator.java:57)
    at com.tcs.fi.business.FIReInitiator.reInitiateFI(FIReInitiator.java:39)
    at com.tcs.fi.business.Test.main(Test.java:11)
Caused by: java.sql.SQLException: Fail to convert to internal representation: TMFI10000031A
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:239)
    at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(OracleTypeADT.java:274)
    at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(OracleTypeUPT.java:115)
    at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:1314)
    at oracle.sql.ARRAY.<init>(ARRAY.java:152)
    at org.springframework.data.jdbc.support.oracle.SqlArrayValue.createTypeValue(SqlArrayValue.java:91)
    at org.springframework.jdbc.core.support.AbstractSqlTypeValue.setTypeValue(AbstractSqlTypeValue.java:58)
    at org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:267)
    at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
    at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
    at org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:947)

Kindly help.

1 Answer 1

2

I solved it using

Map in = new HashMap();


       in.put("P_FAN_NO",reFIRequest.getFanNo());  
       Object[][] refIDS = new String[reFIRequest.getApplicantReferenceID().size()][1];

      for(int i = 0 ; i < reFIRequest.getApplicantReferenceID().size() ; i++){
         refIDS[i][0] = reFIRequest.getApplicantReferenceID().get(i);
      }
       in.put("P_REF_ID", new SqlArrayValue(refIDS));
       in.put("P_COMMENTS", reFIRequest.getComments());
       in.put("P_BILLING_FLAG", reFIRequest.getFiBillingFlag());
       Map  result = reFIJdbcCall.execute(in);
       String status = (String)result.get("P_STATUS");

Seems like it was expecting a 2D-Array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.