View previous topic :: View next topic |
Author |
Message |
sakreg Beginner
Joined: 28 Feb 2005 Posts: 80 Topics: 26
|
Posted: Wed Nov 16, 2005 3:35 am Post subject: Merge of Datasets with Table names from Input |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Nov 16, 2005 5:21 am Post subject: |
|
|
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 |
|
|
sakreg Beginner
Joined: 28 Feb 2005 Posts: 80 Topics: 26
|
Posted: Thu Nov 17, 2005 12:05 am Post subject: |
|
|
Great Thoughts. Thanks Kolusu. Works as I expected.
I learnt something new today. |
|
Back to top |
|
|
|
|