Considerations for writing a high-level language program
Here are the considerations for writing a high-level language program that processes a database file using the Open Query File (OPNQRYF) command.
If you omit the FORMAT parameter, your high-level language program is coded as if you were directly accessing the database file. Selection or sequencing occurs external to your program, and the program receives the selected records in the order you specified. The program does not receive records that are omitted by your selection values. This same function occurs if you process through a logical file with select/omit values.
If you use the FORMAT parameter, your program specifies the same file name used on the FORMAT parameter. The program is written as if this file contained actual data.
If you read the file sequentially, your high-level language can automatically specify that the key fields are ignored. Normally you write the program as if it were reading records in arrival sequence. If the KEYFLD parameter is used on the Open Query File (OPNQRYF) command, you receive a diagnostic message, which can be ignored.
If you process the file randomly by keys, your high-level language probably requires a key specification. If you have selection values, it can prevent your program from accessing a record that exists in the database. A Record not found condition can occur on a random read whether the OPNQRYF command was used or whether a logical file created using DDS select/omit logic was used.
In some cases, you can monitor exceptions caused by mapping errors such as arithmetic overflow, but it is better to define the attributes of all fields to correctly handle the results.
Parent topic:
Using Open Query File (OPNQRYF) command
Related tasks
Using an existing record format in the file