Using Open Query File (OPNQRYF) command

 

By using the Open Query File (OPNQRYF) command, you can open a file to a set of database records that satisfies a database query request.

The OPNQRYF command allows you to perform many data processing functions on database files. Essentially, it acts as a filter between the processing program and the database records. The database file can be a physical or logical file. Unlike the Create Physical File (CRTPF) or Create Logical File (CRTLF) command, the OPNQRYF command creates only a temporary file for processing the data; it does not create a permanent file.

The OPNQRYF command has functions similar to those in data description specifications (DDS) and the CRTPF and CRTLF commands. DDS requires source statements and a separate step to create the file. The OPNQRYF command allows a dynamic definition without using DDS. The OPNQRYF command does not support all of the DDS functions, but it supports significant functions that go beyond the capabilities of DDS. In addition, Query for iSeries™ can be used to perform some of the functions that the OPNQRYF command performs. However, the OPNQRYF command is more useful as a programmer's tool.

The OPNQRYF command parameters also have many functions similar to the SQL SELECT statements. For example, the FILE parameter is similar to the SQL FROM statement, the QRYSLT parameter is similar to the SQL WHERE statement, the GRPFLD parameter is similar to the SQL GROUP BY statement, and the GRPSLT parameter is similar to the SQL HAVING statement. The following list shows the major functions supplied by the OPNQRYF command:

To understand the OPNQRYF command, be familiar with its two processing approaches: using a format in the file, and using a file with a different format. The typical use of the OPNQRYF command is to select, arrange, and format the data so it can be read sequentially by your high-level language program.

 

Parent topic:

Opening a database file

 

Related concepts


SQL programming
Control language

 

Related reference


Open Query File (OPNQRYF) command