Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Reg: Fetch first name and LAst name from continuous stream

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Thu Jul 01, 2010 4:11 pm    Post subject: Reg: Fetch first name and LAst name from continuous stream
Reply with quote

Hi,

I have a table with a column (COLUMN1) declared as VARCHAR. this field is having some data which has the first name<space>last name<spaces>email as a continuous stream.This is the format which is there. Also there is no specific length for firstname and second name and email, it can vary. Consider ,

As -IS
Code:

FNAME1 LNAME1 helli@email.com1
Firstname lastname helli@email.com2
Firstname Lname helli@email.com3
FName LastName helli@email.com4


where I need to extrcat the record till second till the second space. is this possible

To be
Code:

FNAME1 LNAME1
Firstname lastname
Firstname Lname
FName LastName


This To be should be returned through a mainframe Query, Can any one please advice.I need to extract the records until the second space is encountered.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Thu Jul 01, 2010 4:33 pm    Post subject:
Reply with quote

well, you could use the following scalar functions on every row:

select substr(var_char_col,1,locate(' ',var_char_col,posstr(var_char_col,' ') + 1)
(above is untested - give me a while and I will test it),

which I would do if I owned IBM stock and wanted my company to buy more iron,

but, if I was trying to do this in an economic fashion for my company,
I would select the complete var_char_col and use the COBOL UNSTRING to find the names and discard the email-address.
Back to top
View user's profile Send private message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Thu Jul 01, 2010 5:00 pm    Post subject:
Reply with quote

Thank you...Will try it from my end too..
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us