ILE COBOL Language Reference


RELATIVE KEY Clause

The RELATIVE KEY clause identifies a data-name that specifies the relative record number for a specific logical record within a relative file.

RELATIVE KEY Clause - Format
 
>>-RELATIVE--+-----+--+----+--data-name-4----------------------><
             '-KEY-'  '-IS-'
 
 
data-name-4
Must be defined as an unsigned integer data item whose description does not contain the PICTURE symbol P. Data-name-4 must not be defined in a record description entry associated with this relative file. That is, the RELATIVE KEY is not part of the record. Data-name-4 can be qualified.

For reads under sequential access, the RELATIVE KEY data item is updated with the relative record number of the record being made available.

Data-name-4 is required for ACCESS IS SEQUENTIAL only when the START statement is to be used. It is always required for ACCESS IS RANDOM and ACCESS IS DYNAMIC. When the START statement is issued, the system uses the contents of the RELATIVE KEY data item to determine the record at which sequential processing is to begin.

If a value is placed in data-name-4, and a START statement is not issued, the value is ignored and processing begins with the first record in the file.

+-------------------------------IBM Extension--------------------------------+

When the file is opened, the POSITION parameter on the OVRDBF CL command can be used to set the file position indicator. This causes processing to begin with a record other than the first record. For further information, see the CL and APIs section of the Programming category in the iSeries Information Center at this Web site -http://www.ibm.com/eserver/iseries/infocenter.

+----------------------------End of IBM Extension----------------------------+

If a relative file is to be referenced by a START statement, you must specify the RELATIVE KEY clause for that file.

The ACCESS MODE IS RANDOM clause must not be specified for file-names specified in the USING or GIVING phrase of a SORT or MERGE statement.

For EXTERNAL files, data-name-4 must reference an external data item, and the RELATIVE KEY phrase in each associated file control entry must reference that same external data item. (Relative keys are used with subfiles.)

Refer to the Transaction File chapter in the ILE COBOL for AS/400 Programmer's Guide for transaction file considerations.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]