Home » questions » in COBOL can we read a file once and update(REWRITE) it multiple times?

in COBOL can we read a file once and update(REWRITE) it multiple times?

2006-08-07 06:19:08, Category: Programming & Design

Answers

  1. Ted Pack

    On 2006-08-07 08:07:52


    Yes. If you are going to change most of the records on a file you normally open file 1, read it until the end and write file 2, then, in the operating system language, delete file 1 and rename file 2. REWRITE is a verb for changing indexed files, either on-line or if you want to change just a few records. You could have an on-line transaction that rewrote the same record thousands of times in a day.
  2. worriedaboutyou

    On 2006-08-07 07:13:10


    If you are looking for COBOL lessons - this will cost you. I would need to understand what you are trying to accomplish. In COBOL there is enough flexibility to achieve a desired result by more than one means. That is what makes the difference between a programmer and a super programmer! I was the master at this .
  3. AnalProgrammer

    On 2006-08-07 06:59:54


    It does all depend on the type of file. You can read a file multiple times as long as you CLOSE and then re-OPEN the file. This is for a sequential file. Given that you are updating the file then it is probably a keyed file. In this case the file can be read multiple times if the SEARCH command is used.
  4. coolbiker

    On 2006-08-07 06:26:59


    you could always make some extra storage space and move the data there and when you need it copy it again. You could probably set up an if statement to show if user_name = samy davis --move the data to the print area.