Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
The Start Query Management Query (STRQMQRY) command is used to run a query.
To use this command, you must first identify the query that is to be processed. The query is any single Structured Query Language (SQL) statement in a QMQRY object. The SQL statement can also be taken from a query definition (QRYDFN) object when a QMQRY object does not exist.
You can show the output on the display, print it, or store it in a database file.
If the SQL statement inside the query does not create an answer-set, then no report or output file is created. This happens if the SQL statement inside a query is not valid or the SQL statement is not a SELECT clause.
If the query contains substitution variables, the SETVAR parameter can be used to set the variables for the query. If prompting is enabled, query management asks the user to provide a value for each variable that was not set.
Top |
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 | ||
OUTPUT | Output | *, *PRINT, *OUTFILE | Optional, Positional 2 |
QMFORM | Query management report form | Single values: *SYSDFT, *QMQRY Other values: Qualified object name |
Optional |
Qualifier 1: Query management report form | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
OUTFILE | File to receive output | Qualified object name | Optional |
Qualifier 1: File to receive output | Name | ||
Qualifier 2: Library | Name, *CURLIB, *LIBL | ||
OUTMBR | Output member options | Element list | Optional |
Element 1: Member | *FIRST | ||
Element 2: Replace or add records | *REPLACE, *ADD | ||
DATETIME | Date and time | *YES, *NO | Optional |
PAGNBR | Page numbers | *YES, *NO | Optional |
RDB | Relational database | Simple name, *NONE, *CURRENT | Optional |
RDBCNNMTH | Connection Method | *DUW, *RUW | Optional |
USER | User | Name, *CURRENT | Optional |
PASSWORD | Password | Character value, *NONE | Optional |
NAMING | Naming convention | *SYS, *SQL, *SAA | Optional |
ALWQRYDFN | Allow information from QRYDFN | *NO, *YES, *ONLY | Optional |
SETVAR | Set variables | Values (up to 50 repetitions): Element list | Optional |
Element 1: Variable name | Character value | ||
Element 2: Variable value | Character value |
Top |
Specifies the query management query (QMQRY) to be run.
This is a required parameter.
Qualifier 1: Query management query
Qualifier 2: Library
Top |
Specifies whether the output from the command is shown at the requesting work station, printed with the job's spooled output, or directed to a database file.
Top |
Specifies which query management report form is to be applied to the answer-set to format the printed or displayed output.
Single values
Qualifier 1: Query management report form
Qualifier 2: Library
Top |
Specifies the database file that receives the query output. If the file specified does not exist, the system creates it in the specified library as a table in a collection. If the file is created by this function, the authority for users without specific authority is *EXCLUDE.
Qualifier 1: File to receive output
Qualifier 2: Library
Top |
Specifies the database file member to which the output is directed.
Element 1: Member
Element 2: Replace or add records
Top |
Specifies whether the system date and time are printed on the bottom of each page.
Top |
Specifies whether page numbers are printed on the bottom of each page.
Top |
Specifies the relational database that is accessed during the processing of this command.
With *RUW connection management, if the user is connected to a remote database, *OUTFILE cannot be specified on the OUPUT parameter.
With *DUW connection management, if the user is connected to a remote database and OUTPUT(*OUTFILE) is specified, the connection is set to local for the *OUTFILE processing and then the remote connection is restored when the STRQMQRY command is completed.
With *RUW connection management, if the relational database specified is a remote database and OUTPUT(*OUTFILE) is specified, the connection is reset to local for the *OUTFILE processing and remains local when the STRQMQRY command is completed.
With *DUW connection management, if the relational database and OUTPUT(*OUTFILE) is specified, the connection is set to local for the *OUTFILE processing and then the remote connection is restored upon completion of the STRQMQRY command.
Top |
Specifies the connection method to use.
Top |
Specifies the user name sent to the remote system when starting the conversation.
Top |
Specifies the password to be used on the remote system.
Top |
Specifies the naming convention used for naming objects.
Top |
Specifies whether query or form information is taken from a query definition (QRYDFN) object when no query management query (QMQRY) or query management form (QMFORM) object can be found using the specified object name. Any information that has to be derived in this way is discarded when the command completes. No query management object is created.
Top |
Specifies the variables that are set by query management before the query is run. Up to 50 variables can be set.
Element 1: Variable name
Element 2: Variable value
Top |
Example 1: Displaying Query Output
STRQMQRY QMQRY(MYLIB/MYQRY) QMFORM(FORM1)
This command runs query management query MYQRY located in library MYLIB. The library list is searched for form FORM1, which is used for the output sent to the display.
Example 2: Taking Information From Either QMQRY or QRYDFN
STRQMQRY QMQRY(MYLIB/MYQRY) QMFORM(FORM1) ALWQRYDFN(*YES)
This command runs query management query (QMQRY) MYQRY located in library MYLIB. If QMQRY object MYQRY is not found in library MYLIB, the information is taken from query definition (QRYDFN) MYQRY located in library MYLIB. The library list is searched for query management form FORM1 whose information is used to format the output. If QMFORM object FORM1 is not found in the library list, the library list is searched for QRYDFN FORM1, and that information is used to format the output shown on the display.
Example 3: Printing Query Output
STRQMQRY QMQRY(MYLIB/QUERY1) OUTTYPE(*PRINTER)
This command runs query QUERY1 located in library MYLIB. The report is formatted and printed on the printer specified in the printer file associated with the query session.
Example 4: Sending Output to an Existing File
STRQMQRY QMQRY(*CURLIB/MYQRY) OUTPUT(*OUTFILE) OUTFILE(MYTAB) OUTMBR(*FIRST *ADD)
This command runs the query named MYQRY located in the current library for the user's job. The selected data records are added to the previously created table named MYTAB in collection MYCOL.
Example 5: Running a Query Containing Substitution Variables
STRQMQRY QMQRY(MYQUERY) SETVAR((VAR1 'select * from mytable') (VAR2 'where salary > 15000'))
This command runs query MYQUERY, which contains only substitution variables, &VAR1 and &VAR2. These two variables contain the entire structured query language (SQL) statement.
Example 6: Changing a Variable
STRQMQRY QMQRY(QRYNAME) SETVAR((LASTNAME '''Smith'''))
This command runs query QRYNAME, setting the variable LASTNAME to the value, 'Smith'.
Top |
*ESCAPE Messages
Top |