Passing variable values to an initial procedure
When you supply the name of an initial procedure on the DSQSRUN parameter, you can also supply values for one or more variables contained in the procedure.
Follow these rules when you specify variables for the DSQSRUN parameter:
- Put parentheses around the variable parameter list.
- Precede the variable name with an ampersand, and ensure that the string is in a variable_name=value format.
- Ensure that the combined total of characters for the procedure name and the variable parameter list is 98 characters or less.
- Separate the variable parameter specifications using a single comma, one or more blanks, or a combination of a comma and blanks.
The following table lists the number of ampersands required to use a variable in each environment.
|Environment||Number of additional ampersands||Example|
|TSO without ISPF||0||&variable=value|
|TSO with ISPF||1||&&variable=value|
|TSO without ISPF using CLISTs||2||&&&variable=value|
|TSO with ISPF using CLISTs||3||&&&&variable=value|
When you specify the name of an initial procedure, QMF issues a RUN PROC command that runs the procedure. When you use variables in your procedure, the values you supply for these variables must conform to the syntax used for passing variables on a RUN command.
For example, suppose you frequently need two pieces of information about employees in your organization. One piece of information is the name of the employee, and the other varies. You might define a query that returns values for the NAME column and uses a variable for the name of the other column. The following figure shows an example query and procedure. The figure also shows how to pass a value for the variable when you enter the DSQSRUN parameter, and shows the resulting RUN PROC command that QMF issues.
The next figure shows a similar example, but instead of passing one column name to the procedure, it allows you to pass several, which return the employee's name, the department, and the employee's salary.
The next four examples show how to pass information that you normally supply after the WHERE keyword in a query.
These examples contain character strings, which require special syntax because of how QMF evaluates the values when it processes the RUN PROC command. Special characters (commas, blanks, parentheses, double or single quotation marks, apostrophes, and equal signs) can also be included in the string, as shown in the examples.
The first of these four examples shows a query that returns the
names and employee numbers of all the managers in an organization.
When you pass the character string
MGR on the DSQSRUN
parameter, be sure to enclose the value in single quotation marks.
The second of the four examples shows how to pass variable values
that contain commas. Enclose the value
SAN JOSE, CA in
single quotation marks because it contains a comma.
The third of the four examples with character strings shows how to pass variable values that contain single quotation marks (for example, an apostrophe in a name). When you pass the value on the DSQSRUN parameter, be sure to enclose the value in single quotation marks and use two single quotation marks for the apostrophe instead of one.
The last of the four examples shows how to pass more than one variable value on the RUN command.