Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
To fetch value separated by commas from a DB2 column

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: To fetch value separated by commas from a DB2 column
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: 2418
Location: Hampshire, UK

PostPosted: Fri Feb 28, 2020 5:18 pm    Post subject: Reply to: To fetch value separated by commas from a DB2 column
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    Post subject:
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: 2418
Location: Hampshire, UK

PostPosted: Fri Feb 28, 2020 6:53 pm    Post subject: Reply to: To fetch value separated by commas from a DB2 column
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    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 COnvert a column with mix of hex ,cha... shub2204 DB2 5 Fri Oct 02, 2020 2:20 pm
No new posts Fetch the Dataset names from inside m... kalyan94 TSO/ISPF 18 Wed Jun 17, 2020 2:06 pm
No new posts How to fetch the latest record from a... Dinesh Mani DFSORT/ICETOOL 8 Tue Jun 02, 2020 5:34 pm
No new posts Need SQL for two latest records havin... Q5P418 DB2 10 Sun May 10, 2020 8:24 am
No new posts Issue while fetching a column(Nullabl... VINAY PALLELA DB2 18 Tue Mar 31, 2020 9:33 pm

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