FLOAT类型转为字符类型的一个特殊用法

1094阅读 0评论2012-02-07 TOMSYAN
分类:Oracle

在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的过程。
上一篇:SMON: Failed to acquire SEG2
下一篇:Table columns position and performance impact