14.6.4 Reading Records
The GET statement moves a record from a file to a record
buffer and makes the data available for processing. GET
statements are valid on sequential, relative, and indexed files.
You should not use GET statements on terminal-format files
or virtual array files.
For sequential files, a sequential GET retrieves the next
record in the file. For relative files, a sequential GET re-
trieves the next existing record. For indexed files, a sequential
GET retrieves the record with the next ascending or de-
scending value in the current key of reference, depending on
that key's collating sequence.
Table 14-2 shows the current record and next record point-
ers after a GET operation. Note that the values of these
pointers vary, depending on whether or not the previous
operation was a FIND.
If you precede a sequential GET operation with a FIND op-
eration, the current record is the one located by FIND. If you
do not perform a FIND operation before a sequential GET
operation, the current record is the next sequential record.
The following example shows the use of the GET operation to
sequentially access records in an indexed file. The example
opens an indexed file and displays the first 25 records with
serial numbers greater than AB2721 in ascending primary
key value order.
EXAMPLE: Click to display EXAMPLE.
The following example performs random GET operations by
specifying a record number:
EXAMPLE: Click to display EXAMPLE.
You can specify an ALLOW clause in a GET statement if
you have opened the file with ACCESS MODIFY or ACCESS
WRITE and UNLOCK EXPLICIT. The ALLOW clause lets
you control the type of lock RMS places on the retrieved
record. ALLOW NONE specifies that no other users can ac-
cess this record (this is the default). ALLOW READ lets other
access streams have read access to the record. That is, other
users can retrieve the record, but cannot perform DELETE,
PUT, or UPDATE operations on it. ALLOW MODIFY lets
other access streams perform GET, DELETE, or UPDATE
operations on the record.
If you are trying to access a locked record, BASIC signals
``Record/bucket locked'' (ERR=154). However, if you only
need to read this record, you can override the lock with the
REGARDLESS clause. The REGARDLESS clause allows
you to read a locked record. Use caution when using the
REGARDLESS clause because a record accessed in this way
may be in the process of being changed by another program.
Alternatively, you can also specify the WAIT clause on a
GET statement; the WAIT clause allows you to handle record
locked conditions by waiting for the record to become avail-
able. Note that if a WAIT clause is specified on a GET
operation to a unit-record device such as a terminal, the in-
teger expression indicates how long to wait for the I/O to
complete, rather than how long to wait on a record locked
condition. For more information, see Section 14.6.9.