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 

Query for removing Space and Unstring

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Wed Jul 12, 2006 3:48 am    Post subject: Query for removing Space and Unstring Reply with quote

Hi,

I have a db2 table called as "Emptable" with 5 fields.

rollno - 10
Name - 25
halltino - 10
adress - 25
pincode - 10
....

My requirement is:

If there is a space in Halltino, remove the part after space.

Ex:

1)if Halltino='1234 56789' remove the value after space.then it will be halltino='1234'
2)if Halltino='1 3456789' remove the value after space.then it will be halltino='1'
3)if Halltino='1 3 56789' remove the value after space.then it will be halltino='1'

Could any one pls. tell me the query to get this.

Regards
nadh
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Jul 12, 2006 4:23 am    Post subject: Reply with quote

nadh,

Try this

Code:

SELECT SUBSTR(HALLTINO,1,POSSTR(HALLTINO,' ') - 1)
  FROM TABLE


Check this link which explains in detail about POSSTR

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/3.2.58?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
Jaya
Beginner


Joined: 02 Sep 2005
Posts: 77
Topics: 10
Location: Cincinnati

PostPosted: Wed Jul 12, 2006 5:18 am    Post subject: Reply with quote

Nadh,

Please try this...

Code:

UPDATE Emptable
SET halltino=SUBSTR(halltino,1,POSSTR(halltino,' ') - 1)
WHERE ...;


Thanks,
Jaya.
_________________
"Great spirits have always encountered violent opposition from mediocre minds."
-Albert Einstein
Back to top
View user's profile Send private message
Jaya
Beginner


Joined: 02 Sep 2005
Posts: 77
Topics: 10
Location: Cincinnati

PostPosted: Wed Jul 12, 2006 5:24 am    Post subject: Reply with quote

oops!!...The solution is already posted. I forgot to click the submit button earlier. Sad

Jaya..
_________________
"Great spirits have always encountered violent opposition from mediocre minds."
-Albert Einstein
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