VMS Help  —  COBOL  PROCEDURE_DIVISION, READ
  For sequential access files, the READ statement makes the next logical
  record available.

  For random access files, READ makes a specified record available.

1  –  1format_sequential

  For sequentially accessed files, the READ statement makes the next logical
  record in the sequence available.

  Format 1 -

   READ file-name [ NEXT     ] RECORD [ INTO dest-item ]
                  [ PREVIOUS ]
                  [ PRIOR    ]

       [ WITH [ NO ] LOCK       ]
       [ REGARDLESS OF LOCK     ]
       [          { UPDATERS  } ]
       [ ALLOWING { READERS   } ]
       [          { NO OTHERS } ]

       [ AT END stment ] [ NOT AT END stment ]

       [ END-READ ]

1.1  –  file-name

  is the name of a file described in the Data Division.  It cannot be a
  sort or merge file.

1.2  –  dest-item

  is the identifier of a data item that receives the record accessed by
  the READ statement.

1.3  –  stment

  is an imperative statement executed for an at end or not at end
  condition.

2  –  2format_random_dynamic

  For randomly accessed files, READ makes a specified record available.

  Format 2 -

   READ file-name RECORD [ INTO dest-item ]

       [ WITH [ NO ] LOCK       ]
       [ REGARDLESS OF LOCK     ]
       [          { UPDATERS  } ]
       [ ALLOWING { READERS   } ]
       [          { NO OTHERS } ]

       [ KEY IS key-data ]

       [ INVALID KEY stment ] [ NOT INVALID KEY stment ]

       [ END-READ ]

2.1  –  file-name

  is the name of a file described in the Data Division.  It cannot be a
  sort or merge file.

2.2  –  dest-item

  is the identifier of a data item that receives the record accessed by
  the READ statement.

2.3  –  key-data

  is the data-name of a data item or the segmented-key name specified
  as a record key for file-name.  It can be qualified. This clause is not
  used on RELATIVE files.

2.4  –  stment

  is an imperative statement executed for an invalid key or not invalid
  key condition.
Close Help