Convert Varchar to Float via Domain Calculated Fields

0

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: 1 year 7 months ago

1 Answer:

0

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
8407
Joined: Jun 16 2014 - 6:30am
Last seen: 18 hours 31 min ago
Feedback
randomness