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 

how to remove the leading chars?

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


Joined: 10 Oct 2006
Posts: 12
Topics: 5

PostPosted: Wed Nov 08, 2006 2:40 am    Post subject: how to remove the leading chars? Reply with quote

Hi,
can some one help me please?
Maybe the question is silly and dummy, but I have stopped with it.
I need to select some values from tables without leading chars, for ex, without leading zeroes.
But it looks like STRIP function doesn't work for it:
select strip(char(decimal_value),L,'0') from some.table
I mean I can remove trailing zeroes having specified T or B argument,
but I can do nothing with leading zeroes.
Maybe I do something wrong.
Can you please help with it?

Thanks in advance,
Anta
Back to top
View user's profile Send private message
karthikeyan
Beginner


Joined: 29 May 2004
Posts: 16
Topics: 4
Location: chennai

PostPosted: Wed Nov 08, 2006 5:40 am    Post subject: Can you plesae prvoide me with SQLCODE error Reply with quote

Anta,
I tried executing the same Query that you have used it but it works well for me. May I know the Error that you are facing while executing this Query??

Thanks
Karthik
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Anta
Beginner


Joined: 10 Oct 2006
Posts: 12
Topics: 5

PostPosted: Wed Nov 08, 2006 6:49 am    Post subject: Reply with quote

Karthik,

thank you for your reply.
No, it doesn't work for me.

If I run
select char(decimal_value)
from some.table
I receive:
0000000012.000000

When I run
select strip(char(decimal_value),L,'0')
from some.table
I receive the same:
0000000012.000000

But for T (trailing) the picture is changed:
select strip(char(decimal_value),T,'0')
from some.table
0000000012.

I expected that L-operand allows to remove the leading zeroes
but failed with it.

Anta
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Nov 08, 2006 7:39 am    Post subject: Reply with quote

what is the pic definition for the host variable receiving the data from DB2?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Nov 08, 2006 8:32 am    Post subject: Reply with quote

Anta,

The reason your strip did not work is because, the CHAR scalar functions puts a blank in the first character.If the column is negative, the first character of the result is a minus sign. Otherwise, the first character is a blank,which means that a positive value always has one leading blank. So when you are using the strip , the leading character is not zero. So it does not remove the leading zeroes. In order to remove the leading zeroes you need to use the CAST function which does not return the leading blank.

Try this

Code:

SELECT STRIP(CAST(decimal_value AS CHAR(20)),L,'0')
  FROM some.table


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
Anta
Beginner


Joined: 10 Oct 2006
Posts: 12
Topics: 5

PostPosted: Wed Nov 08, 2006 8:35 am    Post subject: Reply with quote

Dick,

I unload the table using sql and form.
In the form this column is defined as char(16).
But even in qmf I can only remove trailing chars, not leading chars - I mean using strip function.

Anta
Back to top
View user's profile Send private message
Anta
Beginner


Joined: 10 Oct 2006
Posts: 12
Topics: 5

PostPosted: Thu Nov 09, 2006 3:17 am    Post subject: Reply with quote

Kolusu,

thank you a lot!
It is what I need.
Thank you!

With kind regards,
Anta
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