Starting QMF for TSO from QMF for Workstation and running a linear procedure
This example shows how to start QMF for TSO from QMF for Workstation and run a simple linear procedure that queries the Q.STAFF sample table for rows that meet specific criteria for employee name, department, and job.
About this task
The query is named STAFFQUERY:
SELECT * FROM Q.STAFF WHERE NAME = &NAME AND DEPT = &DEPT AND JOB = &JOB
The example QMF procedure that runs this query is named STAFFPROC:
SET GLOBAL (DSQEC_CC=0 --Turn off carriage control for printing RUN QUERY STAFFQUERY (&&NAME = &NAME &&DEPT = &DEPT &&JOB = &JOB PRINT REPORT (PR= ' '
Code 1 PRINT REPORT command for each result set to be returned to the calling program. To receive report output back in a result set, the PRINTER option of the PRINT REPORT command must be set to a string of blanks. If you have several PRINT REPORT commands in the procedure, you can issue a SET PROFILE command to set the PRINTER option before you code the first PRINT REPORT command so that you do not have to specify the PRINTER option multiple times.
The procedure can include up to 20 PRINT REPORT commands that return result sets. To eliminate carriage control characters from the result sets, set the DSQEC_CC global variable to 0, as shown in the preceding example.
- You can use parentheses as delimiters for the variable values:
This CALL statement:
- Returns to QMF for Workstation a
result set containing the following row from the Q.STAFF sample table:
ID NAME DEPT JOB YEARS SALARY COMM ------ --------- ------ ----- ------ ---------- ---------- 20 PERNAL 20 SALES 8 18171.25 612.45
- Specifies a value of
L2for the trace-level parameter, which traces messages and commands.
- Leaves the L2-destination parameter blank, which specifies that QMF returns the trace output as the last result set. Thus, a total of two result sets are returned when the STAFFPROC procedure ends.
- Specifies English as the language in which QMF runs, denoted by a value of E for the language parameter.
- How the output parameter is defined depends on the software program
that issues the CALL statement. For example, in QMF for Workstation,
the output parameter is defined as a question mark (
- Returns to QMF for Workstation a result set containing the following row from the Q.STAFF sample table:
- You can also pass the variable values without using parentheses
- The following example CALL statement passes a variable value
that contains an apostrophe:
This statement returns the following row to QMF for Workstation as the first result set:
ID NAME DEPT JOB YEARS SALARY COMM ------ --------- ------ ----- ------ ---------- ---------- 40 O'BRIEN 38 SALES 6 18006.00 846.55
The last result set contains any trace output from the stored procedure run.