MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trim Leading Zero

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Wed Jul 26, 2006 1:31 am    Post subject: Trim Leading Zero Reply with quote

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
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Jul 26, 2006 2:37 am    Post subject: Reply with quote

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
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Wed Jul 26, 2006 5:01 am    Post subject: Reply with quote

shekar123, you are right in trimming the spaces, but i am trying to trim leading zeroes.

Does DB2 have no function to do that? Sad
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Jul 26, 2006 7:14 am    Post subject: Reply with quote

Sakreg,

You can use DB2 function STRIP to strip off the characters you want. try this

Code:

SELECT STRIP('0001234',L,'0')
FROM SYSIBM.SYSDUMMY1       


Check this link for a detailed explantion of the STRIP function

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/3.2.79?SHELF=&DT=20010718164132&CASE=

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Wed Jul 26, 2006 7:25 am    Post subject: Reply with quote

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
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Jul 26, 2006 7:42 am    Post subject: Reply with quote

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
View user's profile Send private message
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Wed Jul 26, 2006 8:20 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group