Example 3: Select records using the Open Query File (OPNQRYF) command

This example shows how to select records in a range of values using the Open Query File (OPNQRYF) command.

Assume that you have a Date field specified in the character format YYMMDD and with the "." separator, and you want to process all records for 1988. You can specify:
OVRDBF     FILE(FILEA) SHARE(*YES)
OPNQRYF    FILE(FILEA) QRYSLT('DATE *EQ %RANGE("88.01.01" +
               "88.12.31") ')
CALL       PGM(PGMC)
CLOF       OPNID(FILEA)
DLTOVR     FILE(FILEA)
This example also works if the DATE field has a date data type, the job default date format is YYMMDD, and the job default date separator is the period (.).
Note: For any character representation of a date in one of the following formats, MMDDYY, DDMMYY, YYMMDD, or Julian, the job default date format and separator must be the same to be recognized.
If the ranges are variables defined as character data types and the DATE field is defined as a character data type, specify the QRYSLT parameter as follows:
QRYSLT('DATE *EQ %RANGE("' *CAT &LORNG *CAT '"' *BCAT '"'  +
   *CAT &HIRNG *CAT '")')
However, if the DATE field is defined as a numeric data type, specify the QRYSLT parameter as follows:
QRYSLT('DATE *EQ %RANGE(' *CAT &LORNG *BCAT &HIRNG *CAT ')')
Note: *BCAT can be used if the QRYSLT parameter is in a control language (CL) program, but it is not allowed in an interactive command.