Determining whether duplicate keys exist
The set of keyed sequence access paths used to determine whether the key is a duplicate key differs depending on the input/output (I/O) operation that is performed. You can determine whether duplicate keys exist using the DUPKEYCHK parameter.
For input operations (reads), the keyed sequence access path used is the one that the file is opened with. Any other keyed sequence access path that can exist over the physical file are not considered. Also, any records in the keyed sequence access path omitted because of select/omit specifications are not considered when deciding if the key operation is a duplicate.
For output (write) and update operations, all nonunique keyed sequence access paths of *IMMED maintenance that exist over the physical file are searched to determine if the key for this output or update operation is a duplicate. Only keyed sequence access paths that have *REBLD and *DLY maintenance are considered if the access paths are actively open over the file at feedback time.
When you process a keyed file with a COBOL program, you can specify duplicate key feedback to be returned to your program through the COBOL language, or on the Open Database File (OPNDBF) or Open Query File (OPNQRYF) command. However, in COBOL, having duplicate key feedback returned can cause a decline in performance.
Parent topic:
File processing options