Start Query Management Query (STRQMQRY)

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

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
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

Query management query (QMQRY)

Specifies the query management query (QMQRY) to be run.

This is a required parameter.

Qualifier 1: Query management query

name
Specify the name of the query to run.

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 where the query is located.
Top

Output (OUTPUT)

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.

*
The output produced by the query is formatted with the specified report form and, in interactive mode, sent to the work station that runs the command. If the command is run in batch mode, the output is sent to the default printer used by query management.
*PRINT
The output produced by the query is formatted with the specified query management form, then sent to the default printer used by query management.
*OUTFILE
The output produced by the query is written to a database file (table), which is inserted into a collection.
Top

Query management report form (QMFORM)

Specifies which query management report form is to be applied to the answer-set to format the printed or displayed output.

Single values

*SYSDFT
A default report form is created and used for the report that is printed or displayed.
*QMQRY
The value specified on the Query management query (QMQRY) parameter is used to locate the report form.

Qualifier 1: Query management report form

name
Specify the name of the report form.

Qualifier 2: Library

*LIBL
The library list is used to locate the report form.
*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

File to receive output (OUTFILE)

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

name
Specify the name of the database file that receives the output of the command.

Qualifier 2: Library

*LIBL
All libraries in the job's library list 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

Output member options (OUTMBR)

Specifies the database file member to which the output is directed.

Element 1: Member

*FIRST
The first member in the file receives the output.

Element 2: Replace or add records

*REPLACE
The file is cleared before new records are inserted.
*ADD
New records are added after any existing records.
Top

Date and time (DATETIME)

Specifies whether the system date and time are printed on the bottom of each page.

*YES
The system date and time are printed on the bottom of each page.
*NO
The system date and time are not printed on the bottom of each page.
Top

Page numbers (PAGNBR)

Specifies whether page numbers are printed on the bottom of each page.

*YES
The page numbers are printed on the bottom of each page.
*NO
The page numbers are not printed.
Top

Relational database (RDB)

Specifies the relational database that is accessed during the processing of this command.

*NONE
The local database is accessed. If you are connected to a remote database, the connection is reset to local and remains local until completion of this command. If the connection management method is *DUW the remote connection is left in a dormant state.
*CURRENT
The relational database to which you are currently connected is accessed.

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.

name
Specify the name of the relational database that is accessed. The database you specify must have an entry in the relational database directory.

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

Connection Method (RDBCNNMTH)

Specifies the connection method to use.

*DUW
Connections to several relational databases are allowed. Consecutive CONNECT statements to additional relational databases do not result in the disconnection of previous connections.
*RUW
Only one connection to a relational database is allowed. Consecutive CONNECT statements result in the previous connections being disconnected before a new connection is established.
Top

User (USER)

Specifies the user name sent to the remote system when starting the conversation.

*CURRENT
The user name associated with the current job is used.
name
Specify the user name being used for the application requester job.
Top

Password (PASSWORD)

Specifies the password to be used on the remote system.

*NONE
No password is sent. The user name specified on the USER parameter is not valid if this value is specified.
character-value
Specify the password of the user name specified on the USER parameter.
Top

Naming convention (NAMING)

Specifies the naming convention used for naming objects.

*SYS
The system naming convention is used (database-name/object-name).
*SQL
The SQL naming convention is used (database-name.object-name). If NAMING(*SQL) is specified, the *LIBL value cannot be specified or allowed to be a default value for locating any of the objects specified on other parameters on this command.
*SAA
The SQL naming convention is used (database-name.object-name). If NAMING(*SAA) is specified, the *LIBL value cannot be specified or allowed to be a default value for locating any of the objects specified on other parameters on this command.
Top

Allow information from QRYDFN (ALWQRYDFN)

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.

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

Set variables (SETVAR)

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

character-value
Specify a variable name, from 1 to 30 characters. Because lower-case characters in variable names are changed to upper-case characters when passed to the command processing program, you cannot use this parameter to set values for variables with mixed case names.

Element 2: Variable value

character-value
Specify a variable value, from 0 to 55 characters. If you enclose a value in apostrophes, the apostrophes are removed and double apostrophes within the value are condensed to single apostrophes when the value is passed to the command processing program.
Top

Examples

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

Error messages

*ESCAPE Messages

QWM2701
&1 command failed.
QWM2703
&1 command ended.
QWM2707
*LIBL not allowed when SQL naming applied.
QWM2709
User or password not valid with relational database value.
QWM2710
Password value *NONE only valid with user value *CURRENT.
QWM2712
Character in user name not valid.
Top