Another way to use a model is to set substitution variables for the values that you want to change.
A substitution variable can represent anything that you can write into a query, such as a column name, a search condition, or a specific value. You supply the value for a substitution variable in the "&variable" option on the RUN command or the RUN Command Prompt panel. You can specify the substitution variable on a SET GLOBAL command (instead of RUN) before you run the query.
For example, if you want a list of the employee IDs, names, and jobs of everyone in each of several different departments, you could construct the query like this:
Q.STAFF | ID | NAME | DEPT | JOB | --------+----+--------+-------------+------| | P. | P. AO. | &DEPARTMENT | P. | |
If you run this query without a value on your RUN command, a Prompt panel displays. On the Prompt panel, you fill in a value to substitute for the variable in the query.
When the value to substitute for the variable is one of the following:
You could write the following query, for example:
Q.STAFF | NAME | DEPT | JOB | COMM | --------+-----------+--------+-------+------------| | P. AO. | &DEPT | P. | P. | |
When you run this query, you can specify the variable value:
RUN QUERY (&DEPT = 38
QMF then reads the query like this:
Q.STAFF | NAME | DEPT | JOB | COMM | --------+-----------+--------+-------+------------| | P. AO. | 38 | P. | P. | |
Substitution variables make it possible for other people to use your query. Other users can substitute any value in place of the variable and produce a report specific to their needs. For example, if your RUN command does not supply values for the variable as is shown in the following command:
COMMAND===> RUN REPT4QRY
RUN Command Prompt -- Values of Variables Your RUN command runs a query or procedure with variables that need values. Fill in a value after the arrow for each variable named below: &DEPT ===> ===> ===> ===> ===> ===> ===> ===> ===> ===> ===> Press Enter to execute the command from this panel. 13=Help 15=End Please give a value for each variable name. ISPF Command ===> |
Enter the desired department number after the arrow on the panel. For example:
&DEPT ===> 84
A substitution variable can be a whole name or be included in part of a name.
Substitution variable names: