IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Reg: Fetch first name and LAst name from continuous stream


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 6966
Location: porcelain throne

PostPosted: Thu Jul 01, 2010 4:33 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Code Multi Row fetch in PL1 program PL/I & Assembler 1
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts JCL (SET) variables in input stream data JCL & VSAM 0
No new posts fetch the record number from FMNMAIN ... CLIST & REXX 10
Search our Forums:

Back to Top