You are here: Home > Knowledge Refreshers

KR edition 204 - 206

KR 204 - is same as an earlier KR on HSM

KR-205* Saving Queries in QMF

Hi everyone,
We write queries in QMF and execute them, but when we come out we lose the query, requiring us to create and type the query all over again. Have you wondered if we can save the queries and reuse it?

Saving Queries in QMF

An SQL query can be stored with a specific name and reused later in QMF.

To save a query in QMF, issue the command ‘SAVE’ from the command line of any QMF panel, and you will be presented with a panel where you can enter:

  • The name by which you want to save the query,

  • Option to Display the confirmation panel before replacing a query (If there is already a query object in the database with the name you have chosen for your query, it will be automatically replaced with the new query unless the CONFIRM option is YES.)
    Option to share the query (so that other users can also retrieve and use the queries saved by you)

  • Comment to be saved with the query (the comment text must be enclosed in single quotes)

The query will be saved as <userid>.<Queryname> (where <userid> is your mainframe login ID and <Queryname> is the name you provided to save the query). Alternatively, we can issue the command ‘SAVE QUERY AS <Queryname>’ directly.

Retrieving saved Query:
To get back a saved query, issue the command ‘DISPLAY QUERY <Queryname>’ (if the query was saved in your ID) or ‘DISPLAY QUERY <userid>.<Queryname>’ (if the query was saved in another id <userid> and was Shared).

Running a saved query:
To run a saved query issue the command ‘RUN QUERY <Queryname>’ or ‘RUN QUERY <userid>.<Queryname>’ as required.

Listing saved queries:
To see all the saved queries to which you have access, enter the command LIST QUERIES (to see queries created in your id) or LIST QUERIES (OWNER=ALL) (to see queries created in your id + all the queries which have been shared and can be accessed by you).

Restrictions on Querynames that can be used:
The query name you have chosen cannot be CHART, DATA, FORM, FORM with any name attached, PROC, PROFILE, QUERY, TABLE, or REPORT.
Query names must be no longer than 18 characters.

Extra bits:
Using LIST QUERIES (OWNER=ALL), you will find lots of interesting queries which can be used to get information on tables, indexes etc from catalougue tables such as SYSIBM.SYSINDEXES, SYSIBM.SYSKEYS etc.

KR-206* Listing members in a PDS with wildcard

Hi everyone,
Have you faced a situation, where you have lots of members in a PDS, and you need to find out/ list only members with particular characters in the member name?

Listing members in a PDS with wildcard:

  • It would be very useful to get only the members with particular characters in the member name listed inside the PDS, don’t you think? Guess what, you have a command for absolutely anything in mainframes

  • Say I have a PDS with hundreds of members, and I want to see only the members which ends with ‘LD’.

  • In ISPF 3.4, give the command M /(*LD), in the ‘Command’ area (in front of the PDS name).

  • You will be presented with the DSLIST screen showing only the members in the PDS which end with ‘LD’ – all other members in the PDS will be hidden.

  • If you want the list of all the members which ‘ABC’ anywhere in the member name - Issue the command – M /(*ABC*)

Go back to the main contents page