Retrieve Query Mgmt Query (RTVQMQRY)

Where allowed to run: All environments (*ALL)
Threadsafe: No
Parameters
Examples
Error messages

The Retrieve Query Management Query (RTVQMQRY) command allows you to retrieve Structured Query Language (SQL) source from a query management query (QMQRY) object. The source records are placed into an editable source file member.

You can also retrieve query source from a query definition (QRYDFN) object when the specified QMQRY does not exist.

Top

Parameters

Keyword Description Choices Notes
QMQRY Query management query Qualified object name Required, Positional 1
Qualifier 1: Query management query Name
Qualifier 2: Library Name, *LIBL, *CURLIB
SRCFILE Source file Qualified object name Required, Positional 2
Qualifier 1: Source file Name
Qualifier 2: Library Name, *LIBL, *CURLIB
SRCMBR Source member Name, *QMQRY Optional, Positional 3
ALWQRYDFN Allow information from QRYDFN *NO, *YES, *ONLY Optional
Top

Query management query (QMQRY)

Specifies the query management query whose source is to be retrieved.

This is a required parameter.

Qualifier 1: Query management query

name
Specify the name of the query whose source is to be retrieved.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library for the job is searched. If no library is specified as the current library for the job, the QGPL library is used.
name
Specify the name of the library to be searched.
Top

Source file (SRCFILE)

Specifies the previously-created source physical file into which the query source records are to be written.

This is a required parameter.

Qualifier 1: Source file

name
Specify the name of the source file to receive the query source being retrieved.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library for the job is searched. If no library is specified as the current library for the job, the QGPL library is used.
name
Specify the name of the library to be searched.
Top

Source member (SRCMBR)

Specifies the source file member into which the query source records are being written. If the member existed before running this command, it is cleared before any source records are written to it. If the member does not exist, it is created.

*QMQRY
The member name is the same as the query name specified on the QMQRY parameter.
name
Specify the name of the file member to receive the query source.
Top

Allow information from QRYDFN (ALWQRYDFN)

Specifies whether query information is taken from a query definition (QRYDFN) object when a query management (QMQRY) object cannot be found using the specified object name. Any information that has to be derived in this way is discarded when the command has completed processing. No query management object is created.

*NO
Information is not taken from a QRYDFN object.
*YES
Information is taken from a QRYDFN object when the specified QMQRY object is not found.
*ONLY
Information is taken only from a QRYDFN object. Query management objects are ignored.
Top

Examples

Example 1: Retrieving SQL Source

RTVQMQRY   QMQRY(RPTLIB/SALQRY)  SRCFILE(QRYS)  SRCMBR(EMPQRY)

This command retrieves the source from the query named SALQRY located in the RPTLIB library. The source records that are retrieved are placed into the newly created or cleared member EMPQRY in the first file named QRYS in the user's library.

Example 2: Retrieving Source From Either the QMQRY or the QRYDFN

RTVQMQRY   QMQRY(RPTLIB/SALQRY)  SRCFILE(QRYS)  SRCMBR(EMPQRY)
           ALWQRYDFN(*YES)

This command retrieves the source from the query management query (QMQRY) named SALQRY in the RPTLIB library. If there is no QMQRY object named SALQRY in the RPTLIB library, then the query source is retrieved from the query definition (QRYDFN) named SALQRY in the RPTLIB library. The source records are placed into the newly created or cleared member EMPQRY in the first file named QRYS in the user's library list.

Top

Error messages

*ESCAPE Messages

QWM2701
&1 command failed.
QWM2703
&1 command ended.
QWM2705
Source file &1 in &2 not available.
Top