View previous topic :: View next topic |
Author |
Message |
sakreg Beginner
Joined: 28 Feb 2005 Posts: 80 Topics: 26
|
Posted: Wed Jul 26, 2006 1:31 am Post subject: Trim Leading Zero |
|
|
I am trying to Trim Leading Zero
The below is the one I am using.
Code: |
SELECT TRIM(LEADING '0' FROM '0001234')
FROM SYSIBM.SYSDUMMY1
|
But not successfull, Am I missing something? |
|
Back to top |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Wed Jul 26, 2006 2:37 am Post subject: |
|
|
sakreg,
I am not sure whether you can use TRIM Function in DB2 and i guess it is a Function in Oracle 9i.Check this link which has equivalent Functions across various databases:
http://sqlbible.tar.hu/sqlbible0076.html
Morever u can use LTRIM and RTRIM for the following purposes below:
Code: |
LTRIM function removes blanks from the beginning of a string expression.
RTRIM function removes blanks from the end of a string expression.
|
_________________ Shekar
Grow Technically |
|
Back to top |
|
|
sakreg Beginner
Joined: 28 Feb 2005 Posts: 80 Topics: 26
|
Posted: Wed Jul 26, 2006 5:01 am Post subject: |
|
|
shekar123, you are right in trimming the spaces, but i am trying to trim leading zeroes.
Does DB2 have no function to do that? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
sakreg Beginner
Joined: 28 Feb 2005 Posts: 80 Topics: 26
|
Posted: Wed Jul 26, 2006 7:25 am Post subject: |
|
|
Kolusu,
That is what I was looking for, TRIM is what came to my mind but did not work as expected.
With STRIP it worked as expected.
Thanks for your help |
|
Back to top |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Wed Jul 26, 2006 7:42 am Post subject: |
|
|
Kolusu,
Thanks for the solution.
I had searched in the PDF DB2 Universal Database for OS/390 and z/OS,SQL Reference Version 7 for STRIP Function in the Scalar Functions category and i was able to find it.In the same way i had searched for the same in IBM DB2 Universal Database SQL Reference Volume 1 Version 8 i was not able find the function .What could be the reason as Version 8 is much higher than Version 7 which should be supporting features of 7 too .Can you please correct me where i am wrong ? _________________ Shekar
Grow Technically |
|
Back to top |
|
|
CZerfas Intermediate
Joined: 31 Jan 2003 Posts: 211 Topics: 8
|
Posted: Wed Jul 26, 2006 8:20 am Post subject: |
|
|
In chapter 3 (Functions) page 345 the function STRIP is explained.
My PDF of the SQL reference manual is from 2004 and has the document number SC18-7426-00.
regards
Christian |
|
Back to top |
|
|
|
|