Portal | Manuals | 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: 174
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: 2319
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: 174
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: 2319
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 Issue while fetching a column(Nullabl... VINAY PALLELA DB2 18 Tue Mar 31, 2020 9:33 pm
No new posts OMIT first and last column of a pipe-... karthikb_itpro DFSORT/ICETOOL 1 Fri Nov 01, 2019 8:24 pm
No new posts Need to fetch data from database base... Satandale COBOL Programming 8 Sun Sep 08, 2019 12:01 am
No new posts Fetch first first row in inner join! Vignesh Sid DB2 13 Tue Dec 04, 2018 7:25 pm
No new posts DB2 SQL Query to fetch all instances ... MallikarjunSM DB2 2 Thu Sep 27, 2018 6:46 pm

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