Example 1: Control how the system runs the Open Query File (OPNQRYF) command

This example shows how to optimize for the first set of records.

Assume that you have an interactive job in which the operator requests all records where the Code field is equal to B. Your program's subfile contains 15 records per screen. You want to get the first screen of results to the operator as quickly as possible. You can specify:
OVRDBF    FILE(FILEA) SHARE(*YES)
OPNQRYF   FILE(FILEA) QRYSLT('CODE = "B" ') +
            SEQONLY(*YES 15) OPTIMIZE(*FIRSTIO)
CALL      PGM(PGMA)
CLOF      OPNID(FILEA)
DLTOVR    FILE(FILEA)

The system optimizes handling the query and fills the first buffer with records before completing the entire query regardless of whether an access path already exists over the Code field.