DB2 graphic  QMF Version 8

Using a global variable in a heading or footing

This example uses the SQL query in Figure 110. The query selects and joins columns from the Q.STAFF and Q.ORG tables.

Figure 110. This query 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:

  1. On the QMF command line, enter:
    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.

  2. Run the query to display the default report. Figure 111 shows the report for this example.
    Figure 111. The default report has no page headings or footings.
           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
  3. On the QMF command line, enter:
    SHOW FORM.PAGE

    The FORM.PAGE panel displays.

  4. In line 1 of the PAGE HEADING TEXT field, change the alignment to LEFT, and type the text you want to display as the page heading.

    For this example, type:

    EMPLOYEE DATA FOR THE &11 DIVISION
  5. Press the Report function key to see the changed report.


Go to the previous page Go to the next page

Downloads | Library | Support | Support Policy | Terms of use | Feedback
Copyright IBM Corporation 1982,2004 Copyright IBM Corporation 1982, 2004
timestamp Last updated: March, 2004