[英]Oracle's to_number - What's wrong?
What is wrong with the below format specifier for to_number? to_number的以下格式说明符有什么问题?
SELECT TO_NUMBER('0,22', '0,99') * 100 FROM DUAL;
The result is 2200 instead of 22 -- what am I doing wrong? 结果是2200而不是22 - 我做错了什么?
Try: 尝试:
TO_NUMBER('0,22', '9D99')
Unlike a literal comma, the D
will only match the decimal separator. 与文字逗号不同,
D
只会匹配小数点分隔符。 So if this fails, your decimal separator is probably a .
因此,如果失败,您的小数分隔符可能是一个
.
, not a ,
. 不是
,
。
You can use this command to see the decimal separator and the thousand separator: 您可以使用此命令查看小数分隔符和千位分隔符:
select value from nls_session_parameters
where parameter = 'NLS_NUMERIC_CHARACTERS'
If this returns .,
, the comma is your thousand separator. 如果返回
.,
则逗号为千位分隔符。
To change the separator for a single query, you could: 要更改单个查询的分隔符,您可以:
select TO_NUMBER('0,22','9D99','nls_numeric_characters=,.') from dual;
A quick guess: 0.22 versus 0,22 (same for 9.99 versus 0,99 ) 快速猜测:0.22对0,22(同样为9.99对0,99)
? ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.