Everybody knows that you can pass parameters to a Query Management query. Not everybody knows that you can do the same with a Query/400 query (object type *QRYDFN). It is very easy to set up. 2 shows you an example of the Select Records panel in which variables are used to receive parameters. (The colon is very important. It indicates a dependent value. The variable name following the colon can be any name you want.)
Everybody knows that you can pass parameters to a Query Management query. Not everybody knows that you can do the same with a Query/400 query (object type *QRYDFN). It is very easy to set up. Figure 2 shows you an example of the Select Records panel in which variables are used to receive parameters. (The colon is very important. It indicates a dependent value. The variable name following the colon can be any name you want.)
After setting up the parameters, press Enter to obtain a screen similar to 3. Just supply a name for a "dummy" query or file; it does not have to exist and is not used in this example.
After setting up the parameters, press Enter to obtain a screen similar to Figure 3. Just supply a name for a "dummy" query or file; it does not have to exist and is not used in this example.
To run the query, you can't use the Run Query (RUNQRY) command. You must use the Start Query Management Query (STRQMQRY) command as in the following example:
STRQMQRY QMQRY(QGPL/TEST) + ALWQRYDFN(*YES) + SETVAR((COMPANY 1) + (BRANCH 1) + (ACCOUNT 12000))
The trick to making this work is to specify *YES for the ALWQRYDFN parameter. A value of *YES allows Query Management to run a query definition (*QRYDFN) object instead of a query management (*QMQRY) object. You can either specify values for the parameters on the STRQMQRY command or let Query Management prompt you for them.
Character fields require some additional considerations. When specifying the value to be used by a dependent character field you must enclose the value in single or triple quotes. If you let STRQMQRY prompt you for the value, you must enclose the charcter value in single quotes. If you specify the value through the SETVAR parameter of the STRQMQRY command, you must enclose the value in triple quotes.
Passing Parameters to a Query
Figure 2 Figures 2 - 3
UNABLE TO REPRODUCE GRAPHICS
LATEST COMMENTS
MC Press Online