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 a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.