学无止境
分类: Oracle
2013-12-12 17:01:32
8i以上版本:
十进制-->十六进制
select to_char(123,'XX') from dual;
十六进制-->十进制
select to_number('5D','XX') from dual;
由于转换为十六进制后前面有空格,加上trim处理,如果X的位数不够,会造成无法转换
SQL> select to_char(2343256098840,'XXXXXXXXXX') from dual;
TO_CHAR(234
-----------
###########
SQL> select to_char(2343256098840,'XXXXXXXXXXXXXXX') from dual;
TO_CHAR(23432560
----------------
22194F28818
SQL> select trim(to_char(2343256098840,'XXXXXXXXXXXXXXX')) from dual;
TRIM(TO_CHAR(234
----------------
22194F28818