Cannot cast object with class 'java.lang.String' to class 'java.math.BigDecimal': Domain Calculated Field
Posted on March 15, 2017 at 7:35am
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:
I have a custom str2money function that converts the varchar to money via SQL:
<value>"CASE WHEN ISNUMERIC(" + sqlArgs + ") = 1 THEN CAST(CONVERT(money, " + sqlArgs + ") AS DECIMAL(34,4)) ELSE (0.00) END"</value>