The Open Query File (OPNQRYF) command supports the OPTION parameter to determine the type of processing. The default is OPTION(*INP), so the file is opened for input only. You can also use other OPTION values on the OPNQRYF command and a high-level language program to add, update, or delete records through the open query file.
However, if you specify the UNIQUEKEY, GRPFLD, or GRPSLT parameter, use one of the aggregate functions, or specify multiple files on the FILE parameter, your use of the file is restricted to input only.
A join logical file is limited to input-only processing. A view is limited to input-only processing, if group, join, union, distinct processing, or a user-defined table function is specified in the definition of the view. If the query optimizer needs to create a temporary file to implement the query, then the use of the file is restricted to input only.
OVRDBF FILE(FILEA) SHARE(*YES) OPNQRYF FILE(FILEA) OPTION(*ALL) QRYSLT('FLDA *EQ "ABC" ') CALL PGM(PGMA) CLOF OPNID(FILEA) DLTOVR FILE(FILEA)
Program PGMA processes all records it can read, but the query selection restricts these to records where the Flda field is equal to ABC. The program changes the field value in each record to XYZ and updates the record.
OVRDBF FILE(FILEA) SHARE(*YES) OPNQRYF FILE(FILEA) OPTION(*ALL) QRYSLT('DLTCOD *EQ "X" ') CALL PGM(PGMB) CLOF OPNID(FILEA) DLTOVR FILE(FILEA)
You can also add records by using the OPNQRYF command. However, if the query specifications include selection values, your program can be prevented from reading the added records because of the selection values.