This example uses the SQL query in Figure 110. The query selects and joins columns from the Q.STAFF and Q.ORG tables.
SELECT ID, NAME, DEPT, JOB, YEARS, SALARY, COMM, DEPTNUMB, DEPTNAME, MANAGER, DIVISION, LOCATION FROM Q.STAFF, Q.ORG WHERE DEPT=DEPTNUMB AND DIVISION = &DIVISION ORDER BY DEPT, JOB, LOCATION
In addition, you will use a global variable to specify the division. Global variables allow you to save a QMF object and use it multiple times for different purposes without having to change it.
For more information on using global variables in queries, see DB2 QMF Reference.
To set a global variable:
SET GLOBAL (varname=value
For this example, enter:
SET GLOBAL (DIVISION = '''WESTERN'''
You must reset the global variable using the SET GLOBAL command each time you start a new QMF session. If you do not set global variables before you run your query, QMF displays a panel that prompts you to enter values for the variables.
ID NAME DEPT JOB YEARS SALARY COMM DEPTNUMB D ------ --------- ------ ----- ------ ---------- ---------- -------- - 330 BURKE 66 CLERK 1 10988.00 55.50 66 P 270 LEA 66 MGR 9 18555.50 - 66 P 320 GONZALES 66 SALES 4 16858.20 844.00 66 P 310 GRAHAM 66 SALES 13 21000.00 200.30 66 P 280 WILSON 66 SALES 9 18674.50 811.50 66 P 350 GAFNEY 84 CLERK 5 13030.50 188.00 84 M 290 QUILL 84 MGR 10 19818.00 - 84 M 300 DAVIS 84 SALES 5 15454.50 806.10 84 M 340 EDWARDS 84 SALES 7 17844.00 1285.00 84 M
SHOW FORM.PAGE
The FORM.PAGE panel displays.
For this example, type:
EMPLOYEE DATA FOR THE &11 DIVISION