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

IDMS syntax - Format 1

Read syntax diagramSkip visual syntax diagramFINDOBTAINDBKEYfield1RECORDPAGE-INFOfield2SHARESHREXCLUSIVEEXC

COBOL syntax - Format 1

Read syntax diagramSkip visual syntax diagramFINDOBTAINfield2DB-KEYPAGE-INFOISfield1USAGE-MODEISSHARESHREXCLUSIVEEXC
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.

IDMS syntax - Format 2

Read syntax diagramSkip visual syntax diagramFINDOBTAINCURRENTRECORDSETAREAfield1SHARESHREXCLUSIVEEXC

COBOL syntax - Format 2

Read syntax diagramSkip visual syntax diagramFINDOBTAINCURRENTfield1USAGE-MODEISSHARESHREXCLUSIVEEXC
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.

IDMS syntax - Format 3

Read syntax diagramSkip visual syntax diagramFINDOBTAINNEXTPRIORFIRSTLASTnfield1RECORDfield2SETAREAfield3SHARESHREXCLUSIVEEXC

COBOL syntax - Format 3

Read syntax diagramSkip visual syntax diagramFINDOBTAINNEXTPRIORFIRSTLASTnfield1field2WITHINfield3USAGE-MODEISSHARESHREXCLUSIVEEXC
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.

IDMS syntax - Format 4

Read syntax diagramSkip visual syntax diagramFINDOBTAINCURRENTRECORDfield1SETfield2USING(fieldn)SHARESHREXLUSIVEEXC

COBOL syntax - Format 4

Read syntax diagramSkip visual syntax diagramFINDOBTAINCURRENTfield1WITHINfield2USING(fieldn)USAGE-MODEISSHARESHREXLUSIVEEXC
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.

IDMS syntax - Format 5

Read syntax diagramSkip visual syntax diagramFINDOBTAINOWNERSETfield1SHARESHREXLUSIVEEXC

COBOL syntax - Format 5

Read syntax diagramSkip visual syntax diagramFINDOBTAINOWNERSETWITHINfield1USAGE-MODEISSHARESHREXLUSIVEEXC
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.

IDMS syntax - Format 6

Read syntax diagramSkip visual syntax diagramFINDOBTAINCALCDUPLICATERECORDfield1SHARESHREXLUSIVEEXC

COBOL syntax - Format 6

Read syntax diagramSkip visual syntax diagramFINDOBTAINCALCDUPLICATEfield1USAGE-MODEISSHARESHREXLUSIVEEXC
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.