2017-07-14 51 views
0

如何将字符串转换为双精度或小数?在Exact Online(REST API)中,我尝试使用字符串字段中的十进制值进行计算。例如items.netprice + items.notes。字段items.notes包含十进制值。 试用castconvert结合floatdecimal字符串加倍或小数

+0

目前尚不清楚你在做什么。你能证明你给的东西到目前为止吗? –

回答

1

我会用类似的解决方案:

select case 
     when regexp_replace(c, '[^0-9.]', '', 1, 0, 'g') = c 
     then to_number(c) 
     else null 
     end  
from (select '123.45' c 
     from [email protected] 
     union all 
     select '123invalid.45' c 
     from [email protected] 
     ) 

caseregexp_replace确保非数量为空返回。如果认为有必要,您可能需要将其更改为错误。