Using QMF


Viewing the SQL equivalent of a prompted query

You might want to see the SQL statements that make up a query you create with Prompted Query. For example, you might want to know if your prompted query is equivalent to another SQL query.

When you display the SQL equivalent of a prompted query, you cannot edit, run, or save the query you display.

To display the SQL equivalent of a prompted query:

  1. Display the prompted query on the Prompted Query panel.
  2. Press the Show SQL function key.

    Or you can do the following:

    Enter SHOW SQL on the command line.

    The SQL equivalent of the prompted query displays.

    Figure 56. QMF can display the SQL equivalent of a prompted query.

    +--------------------------------------------------------------------------------+
    | PROMPTED QUERY     USERID.MYQUERY                              LINE    1       |
    |                  +----------------------------------------------------------+  |
    |   Tables:        |                           SQL                            |  |
    |     Q.STAFF(A)   |                                                          |  |
    |     Q.ORG(B)     | The following SQL statement is equivalent to your query. |  |
    |                  |                                              1 to 5 of 5 |  |
    |   Join Tables:   |    SELECT A.DEPT, A.SALARY, B.LOCATION                   |  |
    |     A.DEPT And B |    FROM Q.STAFF A, Q.ORG B                               |  |
    |                  |    WHERE ((B.DIVISION = 'EASTERN')                       |  |
    |   Columns:       |         OR (A.DEPT = 84))                                |  |
    |     DEPT         |         AND (A.DEPT = B.DEPTNUMB)                        |  |
    |     SALARY       +----------------------------------------------------------+  |
    |     LOCATION     | F1=Help  F7=Backward  F8=Forward  F12=Cancel             |  |
    |                  +----------------------------------------------------------+  |
    |   Row Conditions:                                                              |
    |     If DIVISION Is Equal To 'EASTERN'                                          |
    |     Or DEPT Is Equal To 84                                                     |
    |                                                                                |
    |   *** END ***                                                                  |
    |                                                                                |
    |                                                                                |
    +--------------------------------------------------------------------------------+

You will learn more about SQL in Chapter 5, Viewing the Data in the Database Using SQL Statements.


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