You can run a query and get the report without saving the definition of the query only if you are running
interactively. (The query must be saved to run in batch.) However:
v If you are creating a query and choose not to save it, it runs only once and then is lost. To save your
query, you need to supply values for the Library and Query prompts. The query name must be a unique
query name in that library. If not, Query issues a message asking whether you want to replace the
existing query.
v If you are running a query in batch, you must save it in a library other than QTEMP before running the
query.
v If you are changing a query and choose not to save it, it is kept without the changes, and the newly
changed or newly entered values are used only if you run the query now. That is, if you changed an
existing definition, the report shows the results of the changes only one time. If the report is run again,
the results are based on the original definition.
To save a newly changed query, you do not need to supply a library name and query name; if you do,
the original query remains unchanged, and a new query is created with the changes you made. Type
the name of the library in which the query is to be saved. Only an actual library name or *CURLIB can be
specified for the Library prompt. However, if you want to first see a list of libraries from which you can
select one, do the following: move the cursor to this prompt, type a special library name (such as *LIBL)
or a generic library name (in the form of ABC*), and press F4 (Prompt).
If you choose to run the query interactively, type 1 (Run interactively) in the Run option prompt and press
the Enter key. Query shows the report on your display, prints the report on a printer, or places the data
from the query in a database file. For more information on selecting an output device, see Chapter 13,
“Selecting output type and output form in Query for iSeries reports”.
If you choose to submit the query to batch processing, type a 2 (Run in batch) in the Run option prompt
and press the Enter key. The query is submitted to the job queue specified in the job description for your
user profile.
You can create a query for a file member that does not contain any data. If you run the query, no data
shows in the report or is placed in a database file. However, you can press F13 (Layout) on the Exit This
Query display to check your report layout.
Running a Query for iSeries query from the Work with Queries display
From the Work with Queries display, you can only run a query that has been previously saved. The query
runs exactly as it was defined. If you want to change anything about the output device, you must first
change the query and then run it.
To run a query from the Work with Queries display:
1. Select option 8 (Run in batch) to submit the query to the job queue specified in the job description for
your user profile.
2. Select option 9 (Run) to run the query interactively.
3. Type the name of the query. If you do not know the name of the query, “Selecting a Query for iSeries
query name from a list” on page 14 tells you how to see a list of query names.
4. Type the name of the library in which the query is stored. Query assumes it is stored in the library for
your last Query work session or in your current library. If you do not have a current library, Query
assumes it is stored in QGPL. You can change the assumed library name. If you do not know the
name of the library, “Selecting a library for your Query for iSeries queries” on page 16 tells you how to
display a list of library names.
5. Press the Enter key.
170 Query for iSeries Use V5R2