Changing a query
You can change a prompted query at any time. If you saved the query, you must first retrieve the it from the database.
Retrieving a query from the database
To retrieve a query from the database, enter the following on the QMF command line:
DISPLAY QUERY queryname
The Prompted Query panel displays with the query you requested from the database.
Correcting a query that does not successfully run
If you cannot successfully run a query, one or more of the database objects that are specified in the query probably was updated. For example, perhaps a table name was changed or a column was deleted from a table since the last time you ran the prompted query. You cannot change the query from within QMF in these cases. You must convert the query to SQL or export the query to change it.
Adding information to a query
You can add information to a query before or after you save it. You can add specifications and you can change existing specifications.
To add a specification to a query:
- On the Prompted Query panel, press the Specify function key.
- On the Specify panel, enter the number of the specification you want to add.
To add further detail to an existing specification:
- In the echo area, position the cursor on the underscore character that appears to the left of the specification to which you want to add further detail. If a specification is longer than one line, place the cursor on the first line of the specification.
- Press the Insert key.
- Enter the information that you want to add to the query. After you press Enter on the last panel, the Prompted Query panel displays with the information you added.
Alternatively, you can:
- Type INSERT on the command line of the Prompted Query panel. Do not press Enter.
- In the echo area, position the cursor on the underscore character that appears to the left of the specification to which you want to add further detail. If a specification is longer than one line, place the cursor on the first line of the specification.
- Press Enter.
Changing information in a query
You can change column names, row conditions, sort information, and time period specifications in a query. You cannot change table names, but you can delete a table and specify a new one.
To change information in a query:
- In the echo area, position the cursor on the underscore character that appears to the left of the specification that you want to change. If the specification is longer than one line, place the cursor on the first line of the specification. For example, to change a time period specification that is longer than one line, place the cursor on the line that contains the table or view name.
- Press the Change function key.
The appropriate change panel, like the one in the following figure, displays.
Figure 1. QMF displays a panel where you specify changes to a query. PROMPTED QUERY USERID.MYQUERY MODIFIED LINE 1 +--------------------------------------------------------------+ Tables: | Change Column | Q.STAFF | | | Type a column name, expression (A+B, etc.), or a summary | Columns: | function (SUM, etc.). You can use the following arithmetic | NAME | operators: add(+), subtract(-), multiply(*), and divide(/). | > ... | | JOB | ( ) | | ( ) | Row Condit | ( ) | If JOB I | ( ) | | ( ) | *** END ** +--------------------------------------------------------------+ | F1=Help F4=List F12=Cancel | +--------------------------------------------------------------+
- Enter the changes to the information.
The Prompted Query panel displays with the changed information in the echo area.
Deleting information from a query
You can delete any information from a query, including table names.
To delete information from a query:
- Position the cursor on the underscore character that appears to the left of the specification that you want to delete. To delete a specification that is longer than one line, place the cursor on the first line of the specification.
- Press the Delete function key.
Remember the following when you are deleting tables or table joins from a query:
- When you delete a table from a query, QMF also deletes any table joins you created with that table.
- When you delete a table or view from a query, any time period specifications that are based on that table or view are deleted also.
- When you change a query so that two or more of the tables in the query are no longer joined, the Join Tables panel displays. You can link the tables by another common column.