简体   繁体   English

将字符转换为SQL Oracle中的十进制/双精度字符

[英]Char to Decimal/Double in SQL Oracle

Can anyone help me to for below coding, how to convert String to Decimal/Double. 谁能帮我进行以下编码,如何将String转换为Decimal / Double。

I have received the following error when running these code. 运行这些代码时,我收到以下错误。

"Invalid character found in a character string argument of the function "DECFLOAT" “在函数“ DECFLOAT”的字符串参数中找到无效的字符

(case when
(select max(IT.TRACE_QUANTITY) from BRDB.IMPORT_TRACE IT where IT.FILE_NO = IS.FILE_NO and IT.TRACE_TYPE = 'CO' and IT.TRACE_UNIT = '40H') is null
then ''
else decimal('1.125')
end) as "40H"

the reason i convert it is to sum all the numbers i need. 我进行转换的原因是求和所有我需要的数字。 I want to convert '1.125' to double or decimal 我想将“ 1.125”转换为双精度或十进制

Would TO_NUMBER (with appropriate format mask) help? TO_NUMBER (使用适当的格式掩码)会有所帮助吗? For example: 例如:

SQL> select to_number('1.125', '99999D999', 'nls_numeric_characters = .,') result from dual;

    RESULT
----------
     1,125

SQL>

Just use 1.125 directly instead of else decimal('1.125') : 只需直接使用1.125而不是else decimal('1.125')

(case when
(select max(IT.TRACE_QUANTITY) from BRDB.IMPORT_TRACE IT where IT.FILE_NO =  IS.FILE_NO and IT.TRACE_TYPE = 'CO' and IT.TRACE_UNIT = '40H') is null
then ''
else 1.125
end) as "40H"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM