When the KEY phrase is specified, the key data item used for the comparison
is data-name.
When the KEY phrase is not specified, the file position indicator is set
to the record with a key equal to the value contained in the RECORD KEY data
item.
When START statement execution is successful, the RECORD KEY or ALTERNATE
RECORD KEY with which data-name-1 is associated becomes the key of reference
for subsequent READ statements.
When the KEY phrase is specified, the search argument used for the comparison
is data-name-1, which can be:
Note: If the RECORD KEY
is defined as COMP, COMP-3, COMP-4, or COMP-5, the key data item must be the RECORD
KEY itself. A partial key field in the record area cannot be used.
The file position indicator is positioned to the first record in the file
with a record key for a format that satisfies the comparison. If the operands
in the comparison are of unequal length, the comparison proceeds as if the
longer field were truncated on the right to the length of the shorter field.
All other numeric and nonnumeric comparison rules apply, except that the
PROGRAM COLLATING SEQUENCE, if specified, has no effect.
IBM Extension
For a file that specified RECORD KEY IS EXTERNALLY-DESCRIBED-KEY, the following
additional considerations apply:
- The reserved word EXTERNALLY-DESCRIBED-KEY can be specified. This indicates
that the complete key in the record area should be used in the comparison.
- A series of data names can be specified. This allows a partial key field
in the record area to be used (generic START). These data names must follow
the following rules:
- All except the last of the data names specified must be a record key for
a single format that was copied in for the file. The record format in which
they are contained does not have to be the one that can be specified by the
FORMAT phrase.
- The order of these data names (key fields) must match the order of the
keys as defined in DDS; that is, they must be specified from most significant
field to least significant.
- The total number of data names cannot exceed the number of key fields
defined for that record format.
- If the last data name specified in the series is not a key field in the
record area, it must have its left byte occupy the same space as the key field
that is defined at that relative position. If the key field in the record
area at this position is a COMP, COMP-3, COMP-4, or COMP-5 field, only the key field
itself can be used as the data name.
- Only the last key can be reference modified, and the reference modification
starting position must equal 1.
- Table 1 shows the action between the KEY IS phrase and the
FORMAT phrase:
Table 1. Relationship between KEY IS and FORMAT
Phrases| FORMAT Phrase specified |
KEY Phrase |
| Data-Name Series |
Omitted |
EXTERNALLY-DESCRIBED-KEY |
| Yes |
A, B |
C, D |
C, B |
| No |
A, E |
F, G |
F, E |
- A
- The search argument is built using the specified data items.
- B
- The file position indicator is set to the first record in the file of
the format specified with a record key that satisfies the comparison specified
in the key phrase.
- C
- The search argument is built using the key fields in the record area
for the format specified in the FORMAT phrase.
- D
- The file position indicator is set to the first record in the file of
the specified format with a record key equal to the search argument.
- E
- The file position indicator is set to the first record in the file with
a common key for the file that satisfies the comparison specified in the KEY
phrase. If there is no common key, the file position indicator is set to
the first record in the file.
- F
- The search argument is built using the key fields in the record area
for the first record format for the file as defined in the program.
- G
- The file position indicator is set to the first record in the file with
a common key for the file that is equal to the search argument. If there
is no common key, the file position indicator is set to the first record in
the file.
End of IBM Extension
When the KEY phrase is not specified, the key data item used for the EQUAL
TO comparison is the prime RECORD KEY.
- data-name-1
- Can be any of the following:
- The prime RECORD KEY.
- An alphanumeric data item within a record description for a file whose
leftmost character position corresponds to the leftmost character position
of that record key; it may be qualified. The data item must be less than or
equal to the length of the record key for the file.
The file position indicator points to the first record in the file whose
key field satisfies the comparison. If the operands in the comparison are
of unequal lengths, the comparison proceeds as if the longer field were truncated
on the right to the length of the shorter field. All other numeric and nonnumeric
comparison rules apply, except that the PROGRAM COLLATING SEQUENCE clause,
if specified, has no effect.
When START statement execution is successful, the RECORD KEY with which
data-name-1 is associated becomes the key of reference for subsequent READ
statements.
When START statement execution is unsuccessful, the key of reference is
undefined.
IBM Extension
For indexed files of device type DATABASE, the meaning of the comparison
can be affected by the type of key fields in the record area defined for the
file. Key fields on this system can be defined as multiple fields, each of
which can be in ascending or descending sequence. The system establishes
a sequence (keyed sequence access path) for the records based on the values
contained in the record key for the format and the sequencing specified in
DDS. When a START statement is processed, the request is interpreted as follows:
| COBOL Comparison |
System Result |
| GREATER THAN |
AFTER |
| NOT LESS THAN |
EQUAL TO or AFTER |
For example, when a statement is processed using the comparison of GREATER
THAN, a search is made of these sequenced records for the first record after
the search argument specified by the START statement. If the file was sequenced
using descending keys, the file position indicator would point to a record
with a key less than the one specified and not greater than that specified
in the START statement.
End of IBM Extension