Convert Varchar to Float via Domain Calculated Fields

Hi,

 

Is there any way to convert a varchar to a float in a Domain's calculated field. I am pulling data from a MSSQL database.

 

Thanks,

Dennis

dglasberg's picture
Joined: Nov 21 2016 - 8:02am
Last seen: 5 years 6 months ago

1 Answer:

Hi,

you can specify your custom function in WEB-INF\applicationContext-semanticLayer.xml to convert varchar to float.

There is str2int function already defined in the file, within "sqlserverGenerator" bean:

<entry key="str2int">
                    <value>"cast(" + sqlArgs[0] + " as numeric(10,0))"</value>
</entry>

 

You can add your custom one like

<entry key="str2float">
                    <value>"cast(" + sqlArgs[0] + " as float)"</value>
</entry>

then restart the server and use str2float() function in Domain Calculated field

Best regards,
Andrew

asimkin's picture
27791
Joined: Jun 16 2014 - 6:30am
Last seen: 2 years 10 months ago
Feedback
randomness