Use the READ statement to retrieve (READ) records from a file. To read a
record, you must have opened the file INPUT or I-O. You should check the
file status key after each READ statement.
Records in VSAM sequential files can be retrieved only in the sequence in
which they were written.
Records in VSAM indexed and relative files can be retrieved:
Sequentially
According to the ascending order of the key you are using, the RECORD
KEY or the ALTERNATE RECORD KEY, beginning at the current position of
the file position indicator for indexed files, or according to
ascending relative record locations for relative files.
Randomly
In any order, depending on how you set the RECORD KEY or ALTERNATE
RECORD KEY prior to your READ request.
Dynamically
Mixed sequential and random.
With dynamic access, you can switch between reading a specific record
directly and reading records sequentially, by using READ NEXT for
sequential retrieval and READ for random retrieval (by key). See "File
Access Modes" for a complete description of the features of
each access mode.
When you want to read sequentially, beginning at a specific record, use
START before the READ NEXT to set the file position indicator to point to
a particular record.
When you specify START followed by READ NEXT, the next record is read and
the file position indicator is reset to the next record. The file
position indicator can be moved around randomly through the use of START,
but all reading is done sequentially from that point. You can continue to
read records sequentially, or you can use the START statement to move the
file position indicator:
START file-name KEY IS EQUAL TO ALTERNATE-RECORD-KEY
When a direct READ is executed, based on an alternate index for which
duplicates exist, only the first record in the data set (base cluster)
with that alternate key value is retrieved. You need a series of READ
NEXT statements to retrieve each of the data set records with the same
alternate key. A FILE STATUS value of '02' is returned if there are more
records with the same alternate key value to be read; a value of '00' is
returned when the last record with that key value has been read.
No comments:
Post a Comment