Documente Academic
Documente Profesional
Documente Cultură
technical .
corresponaence
File Updating-Still Once More s y n c h r o n i z a t i o n o f the (sequential) the o l d file, the t r a n s a c t i o n s file, o r
files i n v o l v e d b u t c o n s i d e r e d the even the u p d a t e d file. A n y o f t h e m
[ ] I r e a d w i t h g r e a t interest B a r r y p r o b l e m f r o m different viewpoints: c o u l d be privileged.
D w y e r ' s article o n h o w to u p d a t e a
m a s t e r file in the J a n u a r y issue o f PROCEDURE DIVISION.
UPDATE-SEQUENTIAL-FILES.
C o m m u n i c a t i o n s [1]. M y interest was
OPEN INPUT OLD-FILE, TRANSACTION-FILE,
b a s e d o n s o m e w o r k I h a v e d o n e in OUTPUT MASTER-FILE.
the past. A l t h o u g h I h a v e n o t b e e n
a b l e to see all the r e f e r e n c e d litera- PERFORM READ-OLD-RECORD.
PERFORM READ-A-TRANSACTION.
ture ( I d o n o t h a v e a v a i l a b l e M c - PERFORM CLEAR-MASTER-RECORD.
C r a c k e n ' s [2] o r J a c k s o n ' s [3] work), PERFORM CHOOSE-NEXT-FILE-KEY
D i j k s t r a ' s [4] e x a m p l e stresses t h a t PERFORM PROCESS-ONE-FILE-KEY
the k e y to a n e a t s o l u t i o n is the UNTIL CURRENT-KEY=SENTINEL.
buildup of "the merged sequence" of CLOSE OLD-FILE, TRANSACTION-FILE, MASTER-FILE.
STOP RUN.
all the d i f f e r e n t r e c o r d s w i t h the
s a m e key. T h e p r o c e s s i n g o f the se- PROCESS-ONE-FILE-KEY.
quence, o n c e a l r e a d y built, d e p e n d s IF OLD-KEY=CURRENT-KEY
o n the specific case: types o f records, PERFORM INITIAL-STATUS
PERFORM READ-OLD-RECORD
their origin a n d m e a n i n g , a n d the ELSE IF TRANSACTION-KEY=CURRENT-KEY
a n s w e r to special cases a n d se- PERFORM APPLY-TRANSACTION-TO-MASTER
quences. Y o u c a n t h i n k o f a r e c o r d PERFORM READ-A-TRANSACTION
in the o l d file as e q u i v a l e n t to a n ELSE IF MASTER-KEY=CURRENT-KEY
WRITE MASTER
a d d i t i o n r e c o r d in the t r a n s a c t i o n s
PERFORM CLEAR-MASTER-RECORD.
file. PERFORM CHOOSE-NEXT-FILE-KEY
So, a p a r t f r o m the r e q u i r e d prec-
e d e n c e for those records, the t o t a l INITIAL-STATUS.
MOVE OLD TO MASTER
" m e r g e d s e q u e n c e " is t h e basis for
MOVE CURRENT-KEY TO MASTER-KEY.
the answer: h o w to b u i l d it a n d h o w
to process it. CLEAR-MASTER-RECORD
T h e w o r k I r e f e r r e d to initially, MOVE ZEROS TO MASTER
" N o t a s sobre la p r o g r a m a c i 6 n es- MOVE SENTINEL TO MASTER-KEY.
t r u c t u r a d a y la t a r r a c o t i d i a n a : A c - READ-OLD-RECORD.
t u a l i z a c i 6 n d e a r c h i v o s " [5], ( w h i c h READ OLD-FILE
I assume almost nobody has read AT END MOVE SENTINEL TO TRANSACTION-KEY.
abroad), had a didactic objective--
READ-A-TRANSACTION.
to i n t r o d u c e S t r u c t u r e d P r o g r a m - READ TRANSACTION-FILE
m i n g in e v e r y d a y activities. I n it, I AT END MOVE SENTINEL TO TRANSACTION-KEY.
s h o w e d h o w a p r o b l e m w h i c h was
CHOOSE-NEXT-FILE-KEY.
faced every day and which usually IF TRANSACTION-KEY<OLD-KEY MOVE TRANSACTION-KEY TO CUR-
led to i n t r i c a t e a n s w e r s c o u l d be seen RENT-KEY
in fresh n e w w a y s a n d b e n e a t l y ELSE MOVE OLD-KEY TO CURRENT-KEY.
solved. I also gave i m p o r t a n c e to the IF MASTER-KEY<CURRENT-KEY MOVE MASTER-KEY TO CURRENT-KEY