Skip to Content

JDBC lookup Using UDF - error class java.math.BigDecimal:null incompatible with class java.lang.String:null

Hi experts,

   I have requirement to write a query on a Oracle table using a UDF.

This query can return multiple records.

However i get an error "class java.math.BigDecimal:null incompatible with class java.lang.String:null"

I am able to execute the same query using SQL Developer tool without any issues.

here is the code that i use:

//dfrunid is an array of strings (Input)

String Query = " ";

Channel channel = null;

DataBaseAccessor accessor = null;

DataBaseResult resultSet = null;

MappingTrace trace = container.getTrace();

// Query to retrieve the PROP value for the particular source value passed.

Query ="Select DFO_ID from mn_df_object where DFO_ID_PARENT="+dfrunid[0];

try{

//Determine a channel, as created in the Configuration

channel = LookupService.getChannel("<Business Service>","<Channel Name>");

//Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.

accessor = LookupService.getDataBaseAccessor(channel);

//Execute Query and get the values in resultset

resultSet = accessor.execute(Query);

for(Iterator rows = resultSet.getRows();rows.hasNext();){

Map rowMap = (Map)rows.next();

result.addValue((String)rowMap.get("DFO_ID"));

}

}

catch(Exception ex){

result.addValue(ex.getMessage());

}

finally{

try{

if (accessor!=null) accessor.close();

}

catch(Exception e){

result.addValue(e.getMessage());

trace.addInfo(e.getMessage());

}}

Best Regards,

Ravikanth Talagana

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Aug 03, 2012 at 02:05 AM

    The details given are not completely sufficient to analyze thoroughly. But I have a question.

    1) What is your data type defined for the column name DFO_ID in the table?  Is it Big decimal?  If so, then you need to check the following line

    result.addValue((String)rowMap.get("DFO_ID"));

    Because you cast the bigdecimal to string.

    2) What is the value the dfrunid[0] returns?  If this returns string then you need to use  quote inside the query. Check the value type and write below query accordingly.

    Query ="Select DFO_ID from mn_df_object where DFO_ID_PARENT="+dfrunid[0];

    Example:

    Query = "Select DFO_ID from mn_df_object where DFO_ID_PARENT=' " + dfrunid[0] + " ' ";

    Hope this helps.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 03, 2012 at 06:36 AM

    Hi Ravi,

    To cast a Big Decimal to String you should use the method toString() in result.addValue((String)rowMap.get("DFO_ID"));

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 03, 2012 at 05:45 AM

    as seen from error message, you are having issue in casting from bigdecimal to string, check your datatype of the fields and handle it using quote ..

    Add comment
    10|10000 characters needed characters exceeded