On Jun 2, 8:11 pm, Serge Rielau <srie...@ca.ibm.comwrote:
James wrote:
See the following example.
db2 =create table aaa (c1 decimal(10,3));
DB20000I The SQL command completed successfully.
db2 =insert into aaa values (200.03);
DB20000I The SQL command completed successfully.
db2 =select * from aaa;
C1
------------
200.030
1 record(s) selected.
db2 =select char(c1) from aaa;
1
------------
0000200.030
1 record(s) selected.
The result is not what I want. I want to the result to be 200.03 as
CHAR type. How can I do this convert?
Check if STRIP is available on your system.
Also check TRIM which is very similar on new DB2'shttp://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2....
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab- Hide quoted text -
- Show quoted text -
It may be depend on client program whether leading and trailing ZEROs
are displayed.
But, wheather client program returns what format, if you are using DB2
9, you can use strip function to get the format you want.
Like this:
STRIP(CHAR(200.03), B, '0')
Otherwise, you can use LTRIM and RTRIM instead of STRIP functin.
TRANSLATE(RTRIM(LTRIM(TRANSLATE(CHAR(200.03), ' ', '0'))),'0',' ')