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 SORT HELP - SORT A COLUMN and GROUP B... DFSORT/ICETOOL 9
No new posts Remove commas from specific positions... DFSORT/ICETOOL 10
No new posts Uploading from desktop, a CSV file, s... DB2 2
No new posts Add column to existing records using ... JCL & VSAM 2
No new posts fetch the record number from FMNMAIN ... CLIST & REXX 10
Search our Forums:

Back to Top