MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Merge of Datasets with Table names from Input

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Wed Nov 16, 2005 3:35 am    Post subject: Merge of Datasets with Table names from Input Reply with quote

The below queries is build within a JCL that will write the data to a flat file.

SELECT * FROM DBA.TABLE1
WHERE REF_NO = 225138;
SELECT * FROM DBA.TABLE2
WHERE FK_REG_NO = 225138;
SELECT *
FROM DBA.TABLE3
WHERE UNIQE_NO = 225138;
SELECT *
FROM DBA.TABLE4
WHERE PRO_NO = 225138;

I want to know from what table what data is been written to the flat file.
I am using IKJEFT01 utility to extract data. For E.g., let us say that each of the above query produces something like this in the output file

22513801
22513802
22513803
22513804

I now want to append the table name before the begining of each data like this:

TABLE122513801
TABLE222513802
TABLE322513803
TABLE422513804

We can not assume that only 1 row will be fetched from each of the table above. First query might fetch 1 row, second query might fetch 5 rows, third query might fetch 50 rows and fourth query might fetch 12 rows.

What is the best way to do? My thoughts are to have an individual step for each extract and then merge all the four to one flat file. In that case how do I have the Control Cards for merge that would append the table name accordingly to each of the data from the respective flat files? Will SORT utility help to merge in the way we want.

Any other thoughts?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Nov 16, 2005 5:21 am    Post subject: Reply with quote

sakreg,

The simplest way is to modify the sql's to append the table to the unload. try this

Code:

SELECT CHAR('TABLE1')             
      ,A.*                         
  FROM (SELECT * FROM TABLE1)A;
SELECT CHAR('TABLE2')             
      ,B.*                         
  FROM (SELECT * FROM TABLE2)B;


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Thu Nov 17, 2005 12:05 am    Post subject: Reply with quote

Great Thoughts. Thanks Kolusu. Works as I expected.

I learnt something new today.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group