GET #channel, {wait’record,} isam’key(knum) rel kval, varlist
The various forms of the GET statement are used to directly locate and read a record based on a key value. Logically this may be considered a combination of two operations: one to lookup the key and the other to read the record.
channel
the integer expression whose value matches that specified in the OPEN statement.
The optional wait’record clause causes the operation to wait until the record is available (just as if wait'record was specified in the OPEN statement.)
knum
integer expression indicating which logical index to search in. The primary index is 0, the first secondary index is 1, etc.
rel
is one of the following logical comparison operators, relating the key to be found with the key specified:
Relation |
Meaning |
< |
less than |
<= |
less than or equal |
= |
equal |
> |
greater than |
>= |
greater than or equal |
kval
an expression indicating the key to start for in the specified index.
varlist
a list of variables to receive the data. (Although it is technically legal to list several variables, the recommended approach is to specify a single unformatted record variable which is broken into fields by means of lower level MAP statements.)
The fstat variable (from the OPEN statement) will be set according to the key found (or not found). If the key is found, the recno variable will also be set to the record number (although as mentioned before, you don't need to do anything with this information).
For example:
GET'LOCKED #CUS'CHANNEL, WAIT’RECORD, KEY(0) >= "BIG", CUS'REC
The above statement will search the primary index for the record whose key is greater than or equal to "BIG", and if successful, will lock and return the record in the CUS'REC variable and set the Fstat variable (from the OPEN statement) accordingly. To remove the lock, you will need to perform a RELEASE'RECORD or DELETE'RECORD. If the record is found, but is currently locked, then the program will wait.