Using QMF

Using a global variable in a heading or footing

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

Figure 107. 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.

By specifying a global variable for the division, you can run the same query and display a report for any division.

For more information on using global variables in queries, see the QMF Reference, SC26-4716-05.

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 108 shows the report for this example.

    Figure 108. 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.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]