### 7.2.3.2 Unformatted Indexed READ Statement (VMS only)

The unformatted indexed READ statement reads an external record accessed under the keyed mode of access. It assigns the fields of binary data contained in that record to the elements in the I/O list, in the order, from left to right, in which those elements appear in the list. The data is not translated. The amount of data assigned to each element is determined by the element's data type.

The unformatted indexed READ statement reads exactly one record, and can be used only on indexed files. If the number of I/O list elements is less than the number of fields in the record being read, the unused fields in the record are discarded. If the number of I/O list elements is greater than the number of fields, an error occurs.

If a specified key value is shorter than the key field referred to, the key value is matched against the leftmost characters of the appropriate key field until a match is found. The record supplying the match is then read. If the specified key value is longer than the key field that is referred to, an error occurs.

Examples

In the first example, the READ statement reads from the file connected to logical unit 3 and retrieves the record with the value 'SMITH' in the primary key field (bytes 1 to 5). The first two fields of the record retrieved are placed in variables ALPHA and BETA, respectively.

          OPEN (UNIT=3, STATUS='OLD',

    1     ACCESS='KEYED', ORGANIZATION='INDEXED',

    2     FORM='UNFORMATTED',

    3     KEY=(1:5,30:37,18:23))

          READ (3,KEY='SMITH') ALPHA, BETA

In the second example, the READ statement retrieves the first record having a value equal to or greater than 'XYZDEF' in the second alternate key field (bytes 18 to 23). The first field of that record is placed in the variable IKEY.

    READ (3,KEYGE='XYZDEF',KEYID=2,ERR=99) IKEY

Previous Page Next Page Table of Contents