Cannot cast object with class 'java.lang.String' to class 'java.math.BigDecimal': Domain Calculated Field

0

Hi,

I am trying to convert a varchar column in a MSSQL database to a BigDecimal field via a Domain calculated field.

When i bring this calculated field into an Ad Hoc view I get the following error:

2017-03-15 10:33:49,773 ERROR AdhocAjaxController,http-apr-8080-exec-6:954 - ad hoc controller exception: An error occurred while performing the previous request.
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '5500.0000' with class 'java.lang.String' to class 'java.math.BigDecimal'. 5500.00 is the correct amount returned by the database.

The forumla I have in the calculated field is:

str2money(CA_SE_Log.New_Data)

I have a custom str2money function that converts the varchar to money via SQL:

<entry key="str2money">
     <value>"CASE WHEN ISNUMERIC(" + sqlArgs[0] + ") = 1 THEN CAST(CONVERT(money, " + sqlArgs[0] + ") AS DECIMAL(34,4)) ELSE (0.00) END"</value>
</entry>
 
Thanks,
Dennis
dglasberg's picture
Joined: Nov 21 2016 - 8:02am
Last seen: 2 years 4 weeks ago

0 Answers:

No answers yet
Feedback