on 08-02-2012 10:38 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi,
To cast a Big Decimal to String you should use the method toString() in result.addValue((String)rowMap.get("DFO_ID"));
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.