View previous topic :: View next topic
|
Author |
Message |
stly Warnings : 1 New User
Joined: 25 Jul 2005 Posts: 93
|
|
|
|
hi frds i need a program from u.i hav a flat file n a master file.i need to compare the records of flat file with that of master file.if it does not exist i hav to write it in the mater file.can any one suggest optimum code.
i tried comparing the record of flat file with all the records of master file and so on.but it luks lenghty.can any one provide the code. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
stly
Step 1. If not already, sort master file and flat file by record key
Step 2. Pseudo code
Code: |
perform read-old-master-file
perform read-flat-file
perform
until old-master-file-eof
and flat-file-eof
if master-file-key = flat-file-key
then
perform write-from-old-master-file
perform read-old-master-file
perform read-flat-file
else
if master-file-key > flat-file-key
then
perform write-from-flat-file
perform read-flat-file
else
perform write-from-old-master-file
perform read-old-master-file
end-if
end-if
end-perform.
Read-old-master-file.
Read old-master-file
At end
Move ?y? to old-master-file-eof
Move high-key-value to master-file-key.
Read-flat-file.
Read flat-file
At end
Move ?y? to flat-file-eof
Move high-key-value to flat-file-key.
Write-from-old-master-file.
Write new-master-file from old-master-file.
Write-from-flat-file.
Write new-master-file from flat-file.
|
Dave |
|
Back to top |
|
|
stly Warnings : 1 New User
Joined: 25 Jul 2005 Posts: 93
|
|
|
|
thank u very much |
|
Back to top |
|
|
martin9
Active User
Joined: 01 Mar 2006 Posts: 290 Location: Basel, Switzerland
|
|
|
|
hy stly,
why write a program?
use utilities instead...
i.e. dfsort
merge both files, sort them and omit all duplicates...
martin9 |
|
Back to top |
|
|
|