View previous topic :: View next topic
|
Author |
Message |
srj1957
New User
Joined: 15 Dec 2005 Posts: 72 Location: RALEIGH NC, USA
|
|
|
|
Hope you can help me
I have a file (FILE X) on DAY 1 that may have changed on DAY 2 (FILE Y).
I would like to write the records to FILE Z any records that have changed
from FILE Y to FILE Z
Code: |
FILE X
------------
AAAABBBB
BBBBAAAA
BBBBDDDD
CCCCEEEE
FILE Y
------------
AAAABBBC
BBBBAAAA
BBBBDDDD
CCCCEEEX
OUTPUT FILE Z (I want to keep CHANGED RECORDS from File Y)
AAAABBBC
CCCCEEEX
|
|
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
In your example, are the first four characters the key? Or are the first seven characters? How would you know that the BBBBDDDD in file Y is not a changed BBBBAAAA in file X? |
|
Back to top |
|
|
srj1957
New User
Joined: 15 Dec 2005 Posts: 72 Location: RALEIGH NC, USA
|
|
|
|
William Thompson wrote: |
How would you know that the BBBBDDDD in file Y is not a changed BBBBAAAA in file X? |
Thank you for replying so quickly and finding my error in example.
There isn't a key as such, The first 4 will stay constant, but bytes 5-8 could change
This is what I meant to submit
Code: |
FILE X
------------
AAAABBBB
BBBBAAAA
CCCCDDDD
DDDDEEEE
FILE Y
------------
AAAABBBC
BBBBAAAA
CCCCDDDD
DDDDEEEX
OUTPUT FILE Z (I want to keep CHANGED RECORDS from File Y)
AAAABBBC
DDDDEEEX
|
|
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Then the first four are unique keys, no duplicates, right?
for every unique key in file X will there be a matching key in file Y? Or could there be a key in X that was deleted from Y? Or a key in Y that was just added and not present in X? |
|
Back to top |
|
|
srj1957
New User
Joined: 15 Dec 2005 Posts: 72 Location: RALEIGH NC, USA
|
|
|
|
William Thompson wrote: |
Then the first four are unique keys, no duplicates, right?
for every unique key in file X will there be a matching key in file Y? Or could there be a key in X that was deleted from Y? Or a key in Y that was just added and not present in X? |
William,
I appreciate your questions to clarify the data.
Unique Key and No Duplicates
Yes, for every unique key in file X will there be a matching key in file Y.
There will be only updates, - no additions or deletes |
|
Back to top |
|
|
srj1957
New User
Joined: 15 Dec 2005 Posts: 72 Location: RALEIGH NC, USA
|
|
|
|
William Thompson wrote: |
Or could there be a key in X that was deleted from Y? Or a key in Y that was just added and not present in X? |
William,
What effect would there be if BOTH the above statements were to happen ? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
srj1957 wrote: |
Quote: |
Or could there be a key in X that was deleted from Y? Or a key in Y that was just added and not present in X? |
What effect would there be if BOTH the above statements were to happen ? |
You are asking me?
You need to decide what you want on file Z in each case. In other words, is an unmatched key a "changed" record? Or only if it is on Y?
Are you still standing by
Quote: |
Unique Key and No Duplicates
Yes, for every unique key in file X will there be a matching key in file Y.
There will be only updates, - no additions or deletes |
lrecl and recfm? |
|
Back to top |
|
|
srj1957
New User
Joined: 15 Dec 2005 Posts: 72 Location: RALEIGH NC, USA
|
|
|
|
You need to decide what you want on file Z in each case. In other words, is an unmatched key a "changed" record?
William,
Thanks your questions are excellent...
OK..lets say I want any unmatched key to be out put aswell as
Code: |
FILE X
------------
AAAABBBB
BBBBAAAA
CCCCDDDD
DDDDEEEE
FILE Y
------------
AAAABBBC
BBBBAAAA
CCCCDDDD
DDDDEEEX
FFFFJJJJ
OUTPUT FILE Z (I want to keep CHANGED RECORDS and any unmatched from File Y)
-----------------------
AAAABBBC
DDDDEEEX
FFFFJJJJ
LRECL = 8
RECFM = FB |
|
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
What would file Z look like if there was a"GGGG????" in file X but not in Y? |
|
Back to top |
|
|
srj1957
New User
Joined: 15 Dec 2005 Posts: 72 Location: RALEIGH NC, USA
|
|
|
|
William Thompson wrote: |
What would file Z look like if there was a"GGGG????" in file X but not in Y? |
GGGG in file X could be ignored... |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
srj1957,
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/8)
//IN2 DD DSN=... input file2 (FB/8)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/8)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,4,CH) KEEPNODUPS -
WITH(9,4) WITH(17,1) USING(CTL3)
/*
//CTL1CNTL DD *
INREC BUILD=(1,8,17:C'1')
/*
//CTL2CNTL DD *
INREC BUILD=(1,4,9:5,4,17:C'2')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,
INCLUDE=(17,1,CH,EQ,C'2',AND,
5,4,BI,NE,9,4,BI),
BUILD=(1,4,9,4)
/*
|
|
|
Back to top |
|
|
srj1957
New User
Joined: 15 Dec 2005 Posts: 72 Location: RALEIGH NC, USA
|
|
|
|
Thank you all so much for help...
Even though I read the DFSORT tricks and the other DFSORT links I find it hard to come up with a solution...
Thanks again
Steve |
|
Back to top |
|
|
|