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

To fetch value separated by commas from a DB2 column


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Fri Feb 28, 2020 12:56 pm
Reply with quote

Hi All,

I have the DB2 column field in the table TABLEA as follows:

Code:
NAME     AGE      DEPT_CD
RAJ      35       100,200,300


I would like to fetch each of the values of DEPT_CD till comma and then search for matching occurrence in another array

The search can be done on this table TABLEA based on NAME (RAJ) and would like to fetch each of the DEPT_CD values 100, 200 and 300.

Can any one of you please help ?

Thanks
Vinu
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Feb 28, 2020 5:18 pm
Reply with quote

Pease clarify everything that you posted. The title does not seem to match your question. You say you have one column containing values name, age and dept. Dept would appear to be a comma separated list. You want to fetch
each dept value 'until comma' so what about the last one - there is no comma. You want to use that dept value as a key into 'another array' - where is this array? Is it really an array or is it a DB2 table or a COBOL table?
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Fri Feb 28, 2020 5:34 pm
Reply with quote

Hi Nic,

Sorry for the misunderstanding.
Yes last value is not suffixed with comma.
I would like to extract each of the values from DEPT_CD and then later I will use this values in another array (that is second part).

As first part, I would like to extract these values 100, 200 and 300 which is stored in DEPT_CD in separate variables.

Thanks
Vinu
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Feb 28, 2020 6:53 pm
Reply with quote

What is stopping you from SELECTing DEPT_CD into a suitably sized variable and REDEFINEing a table on that variable?
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts Fetch data from programs execute (dat... DB2 3
No new posts first column truncated in search result IBM Tools 13
Search our Forums:

Back to Top