Saturday, December 17, 2011

Adding Records to a File

  The COBOL WRITE statement adds a record to a file, without replacing any
   existing records.  The record to be added must not be larger than the
   maximum record size specified when the file was defined.  You should check
   the file status key after each WRITE statement.


     1 Adding Records Sequentially

     2 Adding Records Randomly or Dynamically
             
    1 Adding Records Sequentially

   Use ACCESS IS SEQUENTIAL and code the WRITE statement to add records
   sequentially to the end of a VSAM file that has been opened with either
   OUTPUT or EXTEND. 
   Sequential files are always written sequentially.
  
   For indexed files, new records must be written in ascending key sequence.
   If the file is opened EXTEND, the record keys of the records to be added
   must be higher than the highest primary record key on the file when the
   file was opened.

   For relative files, the records must be in sequence.  If you include a
   RELATIVE KEY data-item in the SELECT clause, the relative record number of
   the record just written is placed in that data item.
           
   2 Adding Records Randomly or Dynamically

   When you write records to an indexed data set and ACCESS IS RANDOM or
  ACCESS IS DYNAMIC, the records can be written in any order. 

No comments:

Post a Comment