为什么该语句产生错误?我很惊讶遇到错误
SELECT TO_CHAR(1890.55,'$9,999D99') FROM DUAL;
谢谢!
答案 0 :(得分:1)
是数千个分隔符吗?比较!
SQL> SELECT TO_CHAR(1890.55,'$9,999D99') FROM DUAL;
SELECT TO_CHAR(1890.55,'$9,999D99') FROM DUAL
*
ERROR at line 1:
ORA-01481: invalid number format model
SQL> SELECT TO_CHAR(1890.55,'$9G999D99') FROM DUAL;
TO_CHAR(18
----------
$1.890,55
SQL>
[编辑]
您应该知道哪个字符代表千位分隔符,哪个是小数点字符。如果您在TO_NUMBER
函数中添加了另一个参数-NLS_NUMERIC_CHARACTERS
,并将其设置为反映您要转换的值,则它起作用:
SQL> select TO_NUMBER('30470.73', '99999D99', 'nls_numeric_characters=''.,''') res
2 from dual;
RES
----------
30470,73
SQL>