The master file update problem in AWK

5 8 This paper considers how the use o f AWK as a programming vehicle may clarif y certain aspects of the traditional maste r file update problem. We view the updat e problem as having one input stream, rathe r than two separate streams, of old maste r records and transaction records. Thi s permits us to see the programming proble m as the implementation of decision-tabl e logic. For definiteness, let us pose a sampl e master file update problem that has a small scale. In the following, we separat e fields of the records by using a colon , as a delimiter. We have a file o f master records. Suppose that thes e represent inventory records, and consis t of a five-digit item number, an 'M' fo r master record (we shall see T's shortly) , an item name, and the number of suc h things we have in inventory. For example , we might have the following short maste r file : The master file is always sorted by key , which in this case is the item number. We also have a transaction file , consisting of transactions that are to b e applied against the old master records. Each transaction record contains the key , a 'T' for transaction, a code for th e transaction to apply, and transaction-dependent information. For example, we might have the following short transaction file : We restrict ourselves here to one type o f modifying transaction (ADD) whose effec t is to add to the number in inventory, a deleting transaction (REM) whose effect i s to remove the key logically from th e master file, and an inserting transactio n (NEW) which inserts a new key with th e given name field into the file. Erroneous transactions are possible. For example, the second transaction abov e attempts to modify a record which has been logically removed. When an error occur s while processing a given key, we insis t that the corresponding key have the sam e state in the new master file as it did i n the old. If the key existed in the ol d master file, the corresponding record i s copied without alteration to the new master file. If the key did not exist i n the old master file, it will not exist i n the new master file. Sequences …