If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How transform the return value of the round to a non-prefix and non-suffix string?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-22-06, 10:37
zhouhaiming zhouhaiming is offline
Registered User
 
Join Date: Jan 2003
Posts: 74
How transform the return value of the round to a non-prefix and non-suffix string?

Hello, everyone
1.
$ db2 "select char(round(3234.235, 5)) from sysibm.sysdummy1"

1
----------
03234.235

1 record(s) selected.

2.
1
----------------
013435.56464000

1 record(s) selected.

3.
$ db2 "select char(round(1233435.56463621, 5)) from sysibm.sysdummy1"

1
------------------
01233435.56464000

1 record(s) selected.


But I want to get the following value
3234.235
13435.56464
1233435.56464
Reply With Quote
  #2 (permalink)  
Old 09-22-06, 12:19
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534

Try this ..

values(replace(ltrim(rtrim(replace('01233005.56464 000','0',' '))),' ','0'))

I hope there is a simpler method
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 09-22-06, 12:45
rahul_s80 rahul_s80 is offline
Registered User
 
Join Date: Jul 2006
Location: Pune , India
Posts: 433
i dont understand why u r using char


C:\Program Files\IBM\SQLLIB\BIN>db2 values (round(1233435.56463621, 5))

1
------------------
1233435.56464000
Reply With Quote
  #4 (permalink)  
Old 09-22-06, 20:14
zhouhaiming zhouhaiming is offline
Registered User
 
Join Date: Jan 2003
Posts: 74
Thank you for your help! sathyaram_s is right!!
I am doing a project that migrate the stored procedure and function from Oracle to DB2. I found many difference between them!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On