这几天监控程序的运行状况,发日志在记录0.开头的小数时,都只显示了 .*****,查看程序,是这样用的:
select to_char(num) from AAAAAA,测试下:
SQL> select to_char(0.258) from dual;
TO_C
----
.258
确实用to_char()函数有这样的问题,查下资料
TO_CHAR (number) converts n to a value of VARCHAR2 datatype, using the optional number format fmt. The value n can be of type NUMBER, BINARY_FLOAT, or BINARY_DOUBLE. If you omit fmt, then n is converted to a VARCHAR2 value exactly long enough to hold its significant digits.
原来to_char在做转化时,如果你不指定可是,它就按它的格式去做转化,结果就把0给转不见了,所以在做转化时要给定格式
SQL> SELECT to_char(0.2588,'fm999990.99999') FROM dual;
TO_CHAR(0.258
-------------
0.2588
那个9可以根据情况进行增减,格式的个位数字要是0,不然也会显示不出来的。。