FIND/OBTAIN statement
The FIND and OBTAIN statements have the same format. They are therefore described together here. The difference between the two statements is that FIND locates records but it does not retrieve them, whereas OBTAIN locates and retrieves the records.
There are six different FIND and OBTAIN formats available.
Format 1
Obtain or locate a record using the DBKEY.
Syntax
- field1
- A 4-byte binary field or a numeric literal that identifies the database record key.
- field2
- For RECORD, field2 is a record name or a 16-byte
literal that identifies the record to be retrieved.
For PAGE-INFO, field2 must be a 4-byte binary field or a 4-byte hex value.
- SHARE, SHR, EXCLUSIVE, EXC
- Specifies the type of lock to be placed on the record.
Format 2
Obtain or locate CURRENT record, set, or area.
- RECORD/SET/AREA
- Specifies the object type.
- field1
- A record, set, area name, or a 16-byte literal that identifies the record, set or an area to be retrieved or located.
- SHARE, SHR, EXCLUSIVE, EXC
- Specifies the type of lock to be placed on the record.
Format 3
Obtain or locate NEXT, PRIOR, FIRST, LAST, nth record occurrence in a set or an area.
- field1
- A 4-byte binary field, or a positive or negative numeric literal that identifies the record occurrence of a set or area to be retrieved or located.
- field2
- A record name or a 16-byte literal that identifies the record to be retrieved or located.
- field3
- A set or area name or a 16-byte literal that identifies the set or an area to be searched.
- n
- A positive or negative integer that identifies the record occurrence of a set or area to be retrieved or located.
- SHARE, SHR, EXCLUSIVE, EXC
- Specifies the type of lock to be placed on the record.
Format 4
Obtain or locate sorted record from a set.
- CURRENT
- Controls the start of the search.
- field1
- A record name or a 16-byte literal that identifies the record to be retrieved or located.
- field2
- A set name or a 16-byte literal that identifies the set be searched.
- fieldn
- An alphanumeric field or a literal that contains the control statements.
- SHARE, SHR, EXCLUSIVE, EXC
- Specifies the type of lock to be placed on the record.
Format 5
Obtain or locate the owner record within a set.
- field1
- A field name or a 16-byte literal that identifies the set to be retrieved or located.
- SHARE, SHR, EXCLUSIVE, EXC
- Specifies the type of lock to be placed on the record.
Format 6
Obtain or locate a record using the CALC key.
- CALC
- Retrieves the first record.
- DUPLICATE
- Retrieves duplicate records (records after the first record).
- field1
- A record name or a 16-byte literal that identifies the record to be retrieved or located.
- SHARE, SHR, EXCLUSIVE, EXC
- Specifies the type of lock to be placed on the record.
