oracle中不曾熟悉的 to_char、to_number(未完待续)




十进制       十六进制
88               58


用法一:
Converts a HEX number  to  o FLOAT (转换一个十六进制数的浮标)


SQL> select to_number(58,'xx') from dual;

TO_NUMBER(58,'XX')
------------------
                88
                    
               
用法二:
Converts a HEX number to DECIMA       (一个十六进制转换为十进制)

SQL> SELECT TO_NUMBER(58,'xxxxxxx') FROM dual;

TO_NUMBER(58,'XXXXXXX')
-----------------------
                     88

SQL> SELECT TO_NUMBER(58,'xx') FROM dual;

TO_NUMBER(58,'XX')
------------------
                88

SQL> SELECT TO_NUMBER(58,'x') FROM dual;
SELECT TO_NUMBER(58,'x') FROM dual
                 *
ERROR at line 1:
ORA-01722: invalid number

后面x的位数必须大于等于 前面16进制数字的位数

用法三:
Converts a DECIMA  to HEX number  (十进制转换为十六进制)
SQL> select to_char(88,'xx') from dual;

TO_
---
 58

posted @ 2015-11-02 22:15  Oracle-fans  阅读(478)  评论(0编辑  收藏  举报