在ASKTOM网站上看到的一个FLOAT类型转为字符类型的特殊用法。
Tom,
How to extract a number 3.2 to 00320 if the number type
is number(5,2). I use the repacle(to_char(a,'000.00'),'.',null). But there is a balnk or null
behind this. SURPRISE! if i don't want to use function to connect sub sting ,what is the easiest
way ? (oracle 9)
THANKS!
Followup August 27, 2003 - 7am Central time zone:
> create table t ( x number(5,2) );
Table created.
> insert into t values ( 3.2 );
1 row created.
> select '"' || to_char( x, 'fm000v00' ) || '"' from t;
'"'||TO_
--------
"00320"
其实使用下面的方法也是可以的:
SQL> select '"'||replace(to_char(x,'fm000.00'),'.')||'"' from t;'"'||REPLACE(TO_CH
------------------
"00320"
但是比起TOM的方法来说,多了一个REPLACE的过程。
阅读(1047) | 评论(0) | 转发(0) |