File update

Updating a file.

A frequently performed operation on files is the updating of a master file using a transaction file.

A master file is a large semi-permanent file which contains some data that may change whenever a transaction takes place. These transactions are stored on a temporary small file called a transaction file, and this is used to update the master file after a certain period has elapsed (at the end of each day / week etc).

It is important that the master file and the transaction file are sorted on the same key field.

 The system flow chart for the process is shown below:

 

 

There are two input files :

The Old Master File
The Transaction File (sorted)

And one output file :

The New Master File.

 

 

The pseudocode for the update process is as follows :

open master file;  
create new master file;
open transaction file;
while not eof(transaction file) do
  read record from transaction file;
  repeat  
    read record from master file;
    if not matching record then
       write master record to new master file;
  until master and transaction records match;
  update master record;
  write updated master record to new master file;
end while;  
copy remaining master file records to new master file;
close all files;