Oracle SQL:无法将数字转换为char

时间:2016-09-05 15:21:54

标签: oracle oracle11g number-formatting to-char

我有一个表SOME_TABLE,其字段SOME_NUMBER的类型编号。如果我尝试将此字段转换为char,我在某些情况下会收到错误。

此选择

select  id, 
        SOME_NUMBER,
        to_char(SOME_NUMBER,'fm999999990D999999999999','nls_numeric_characters=''.,''') tochar,
        dump(SOME_NUMBER)
from SOME_TABLE 
where id in (
19876,
19886,
19857,
19792,
19810
);

将导致

+-------+---------------+-------------------------+----------------------------+
|  ID   |  SOME_NUMBER  |         TOCHAR          |     DUMP(SOME_NUMBER)      |
+-------+---------------+-------------------------+----------------------------+
| 19792 | 0,00000013147 | 0.00000013147           | Typ=2 Len=4: 189,14,15,71  |
| 19810 | 0,0000001387  | ####################### | Typ=2 Len=3: 189,15,244    |
| 19857 | 0,00000011896 | ####################### | Typ=2 Len=4: 189,13,246,61 |
| 19876 | 0,00000012962 | 0.00000012962           | Typ=2 Len=4: 189,13,97,21  |
| 19886 | 0,00000011896 | ####################### | Typ=2 Len=4: 189,13,246,61 |
+-------+---------------+-------------------------+----------------------------+

此外,我已经注意到错误示例的内部表示与我使用" direct"选择:

select 0.0000001387,dump(0.0000001387) dump from dual union all
select SOME_NUMBER,dump(SOME_NUMBER)from SOME_TABLE where id in (19810);

返回

+--------------+-------------------------+
| 0.0000001387 |          DUMP           |
+--------------+-------------------------+
| 0,0000001387 | Typ=2 Len=3: 189,14,88  |
| 0,0000001387 | Typ=2 Len=3: 189,15,244 |
+--------------+-------------------------+

对于给我错误的记录,这是真的始终,因此这必须与问题相关。

这是Oracle如何管理号码字段的错误吗?或者这是可接受/正确/可能的情况?我怎么能解决这个问题?如果我尝试to_char没有任何格式字符串的字段,连接就会下降......这可能不正常。这是一个已知的问题吗?

0 个答案:

没有答案