Considerations for arranging records

This topic discusses the considerations for using the Open Query File (OPNQRYF) command to arrange records.

The default processing for the OPNQRYF command provides records in any order that improves performance and does not conflict with the order specified on the KEYFLD parameter. Therefore, unless you specify the KEYFLD parameter to either name specific key fields or specify KEYFLD(*FILE), the sequence of the records returned to your program can vary each time you run the same OPNQRYF command.

When you specify the KEYFLD(*FILE) parameter option for the OPNQRYF command, and a sort sequence other than *HEX has been specified for the query with the job default or the OPNQRYF SRTSEQ parameter, you can receive your records in an order that does not reflect the true file order. If the file is keyed, the query's sort sequence is applied to the key fields of the file and informational message CPI431F is sent. The file's sort sequence and alternative collating sequence table are ignored for the ordering, if they exist. This allows users to indicate which fields to apply a sort sequence to without having to list all the field names. If a sort sequence is not specified for the query (for example, *HEX), ordering is done as it was prior to Version 2 Release 3.