ibm-information-center/dist/eclipse/plugins/i5OS.ic.cl_5.4.0.1/strqmqry.htm

583 lines
21 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Start Query Management Query (STRQMQRY)</title>
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body bgcolor="white">
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<a name="STRQMQRY.Top_Of_Page"></a>
<h2>Start Query Management Query (STRQMQRY)</h2>
<table width="100%">
<tr>
<td valign="top" align="left"><b>Where allowed to run: </b>All environments (*ALL)<br>
<b>Threadsafe: </b>No
</td>
<td valign="top" align="right">
<a href="#STRQMQRY.PARAMETERS.TABLE">Parameters</a><br>
<a href="#STRQMQRY.COMMAND.EXAMPLES">Examples</a><br>
<a href="#STRQMQRY.ERROR.MESSAGES">Error messages</a></td>
</tr>
</table>
<div> <a name="STRQMQRY"></a>
<p>The Start Query Management Query (STRQMQRY) command is used to run a query.
</p>
<p>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.
</p>
<p>You can show the output on the display, print it, or store it in a database file.
</p>
<p>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.
</p>
<p>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.
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div>
<h3><a name="STRQMQRY.PARAMETERS.TABLE">Parameters</a></h3>
<table border="1" cellpadding="4" cellspacing="0">
<!-- col1="10" col2="15" col3="30" col4="10" -->
<tr>
<th bgcolor="aqua" valign="bottom" align="left">Keyword</th>
<th bgcolor="aqua" valign="bottom" align="left">Description</th>
<th bgcolor="aqua" valign="bottom" align="left">Choices</th>
<th bgcolor="aqua" valign="bottom" align="left">Notes</th>
</tr>
<tr>
<td valign="top" rowspan="3"><a href="#STRQMQRY.QMQRY"><b>QMQRY</b></a></td>
<td valign="top">Query management query</td>
<td valign="top"><i>Qualified object name</i></td>
<td valign="top" rowspan="3">Required, Positional 1</td>
</tr>
<tr>
<td valign="top">Qualifier 1: Query management query</td>
<td valign="top"><i>Name</i></td>
</tr><tr>
<td valign="top">Qualifier 2: Library</td>
<td valign="top"><i>Name</i>, <b><u>*LIBL</u></b>, *CURLIB</td>
</tr><tr>
<td valign="top"><a href="#STRQMQRY.OUTPUT"><b>OUTPUT</b></a></td>
<td valign="top">Output</td>
<td valign="top"><b><u>*</u></b>, *PRINT, *OUTFILE</td>
<td valign="top">Optional, Positional 2</td>
</tr>
<tr>
<td valign="top" rowspan="3"><a href="#STRQMQRY.QMFORM"><b>QMFORM</b></a></td>
<td valign="top">Query management report form</td>
<td valign="top">Single values: <b><u>*SYSDFT</u></b>, *QMQRY<br>Other values: <i>Qualified object name</i></td>
<td valign="top" rowspan="3">Optional</td>
</tr>
<tr>
<td valign="top">Qualifier 1: Query management report form</td>
<td valign="top"><i>Name</i></td>
</tr><tr>
<td valign="top">Qualifier 2: Library</td>
<td valign="top"><i>Name</i>, <b><u>*LIBL</u></b>, *CURLIB</td>
</tr><tr>
<td valign="top" rowspan="3"><a href="#STRQMQRY.OUTFILE"><b>OUTFILE</b></a></td>
<td valign="top">File to receive output</td>
<td valign="top"><i>Qualified object name</i></td>
<td valign="top" rowspan="3">Optional</td>
</tr>
<tr>
<td valign="top">Qualifier 1: File to receive output</td>
<td valign="top"><i>Name</i></td>
</tr><tr>
<td valign="top">Qualifier 2: Library</td>
<td valign="top"><i>Name</i>, *CURLIB, <b><u>*LIBL</u></b></td>
</tr><tr>
<td valign="top" rowspan="3"><a href="#STRQMQRY.OUTMBR"><b>OUTMBR</b></a></td>
<td valign="top">Output member options</td>
<td valign="top"><i>Element list</i></td>
<td valign="top" rowspan="3">Optional</td>
</tr>
<tr>
<td valign="top">Element 1: Member</td>
<td valign="top">
<b><u>*FIRST</u></b></td>
</tr>
<tr>
<td valign="top">Element 2: Replace or add records</td>
<td valign="top">
<b><u>*REPLACE</u></b>, *ADD</td>
</tr>
<tr>
<td valign="top"><a href="#STRQMQRY.DATETIME"><b>DATETIME</b></a></td>
<td valign="top">Date and time</td>
<td valign="top"><b><u>*YES</u></b>, *NO</td>
<td valign="top">Optional</td>
</tr>
<tr>
<td valign="top"><a href="#STRQMQRY.PAGNBR"><b>PAGNBR</b></a></td>
<td valign="top">Page numbers</td>
<td valign="top"><b><u>*YES</u></b>, *NO</td>
<td valign="top">Optional</td>
</tr>
<tr>
<td valign="top"><a href="#STRQMQRY.RDB"><b>RDB</b></a></td>
<td valign="top">Relational database</td>
<td valign="top"><i>Simple name</i>, <b><u>*NONE</u></b>, *CURRENT</td>
<td valign="top">Optional</td>
</tr>
<tr>
<td valign="top"><a href="#STRQMQRY.RDBCNNMTH"><b>RDBCNNMTH</b></a></td>
<td valign="top">Connection Method</td>
<td valign="top"><b><u>*DUW</u></b>, *RUW</td>
<td valign="top">Optional</td>
</tr>
<tr>
<td valign="top"><a href="#STRQMQRY.USER"><b>USER</b></a></td>
<td valign="top">User</td>
<td valign="top"><i>Name</i>, <b><u>*CURRENT</u></b></td>
<td valign="top">Optional</td>
</tr>
<tr>
<td valign="top"><a href="#STRQMQRY.PASSWORD"><b>PASSWORD</b></a></td>
<td valign="top">Password</td>
<td valign="top"><i>Character value</i>, *NONE</td>
<td valign="top">Optional</td>
</tr>
<tr>
<td valign="top"><a href="#STRQMQRY.NAMING"><b>NAMING</b></a></td>
<td valign="top">Naming convention</td>
<td valign="top"><b><u>*SYS</u></b>, *SQL, *SAA</td>
<td valign="top">Optional</td>
</tr>
<tr>
<td valign="top"><a href="#STRQMQRY.ALWQRYDFN"><b>ALWQRYDFN</b></a></td>
<td valign="top">Allow information from QRYDFN</td>
<td valign="top"><b><u>*NO</u></b>, *YES, *ONLY</td>
<td valign="top">Optional</td>
</tr>
<tr>
<td valign="top" rowspan="3"><a href="#STRQMQRY.SETVAR"><b>SETVAR</b></a></td>
<td valign="top">Set variables</td>
<td valign="top">Values (up to 50 repetitions): <i>Element list</i></td>
<td valign="top" rowspan="3">Optional</td>
</tr>
<tr>
<td valign="top">Element 1: Variable name</td>
<td valign="top">
<i>Character value</i></td>
</tr>
<tr>
<td valign="top">Element 2: Variable value</td>
<td valign="top">
<i>Character value</i></td>
</tr>
</table>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
</div>
<div> <a name="STRQMQRY.QMQRY"></a>
<h3>Query management query (QMQRY)</h3>
<p>Specifies the query management query (QMQRY) to be run.
</p>
<p>This is a required parameter.
</p>
<p><b>Qualifier 1: Query management query</b>
</p>
<dl>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the query to run.
</dd>
</dl>
<p><b>Qualifier 2: Library</b>
</p>
<dl>
<dt><b><u>*LIBL</u></b></dt>
<dd>All libraries in the library list for the current thread are searched until the first match is found.
</dd>
</dl>
<dl>
<dt><b>*CURLIB</b></dt>
<dd>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.
</dd>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the library where the query is located.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.OUTPUT"></a>
<h3>Output (OUTPUT)</h3>
<p>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.
</p>
<dl>
<dt><b><u>*</u></b></dt>
<dd>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.
</dd>
<dt><b>*PRINT</b></dt>
<dd>The output produced by the query is formatted with the specified query management form, then sent to the default printer used by query management.
</dd>
<dt><b>*OUTFILE</b></dt>
<dd>The output produced by the query is written to a database file (table), which is inserted into a collection.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.QMFORM"></a>
<h3>Query management report form (QMFORM)</h3>
<p>Specifies which query management report form is to be applied to the answer-set to format the printed or displayed output.
</p>
<p><b>Single values</b>
</p>
<dl>
<dt><b><u>*SYSDFT</u></b></dt>
<dd>A default report form is created and used for the report that is printed or displayed.
</dd>
<dt><b>*QMQRY</b></dt>
<dd>The value specified on the <b>Query management query (QMQRY)</b> parameter is used to locate the report form.
</dd>
</dl>
<p><b>Qualifier 1: Query management report form</b>
</p>
<dl>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the report form.
</dd>
</dl>
<p><b>Qualifier 2: Library</b>
</p>
<dl>
<dt><b><u>*LIBL</u></b></dt>
<dd>The library list is used to locate the report form.
</dd>
<dt><b>*CURLIB</b></dt>
<dd>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.
</dd>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the library to be searched.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.OUTFILE"></a>
<h3>File to receive output (OUTFILE)</h3>
<p>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.
</p>
<p><b>Qualifier 1: File to receive output</b>
</p>
<dl>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the database file that receives the output of the command.
</dd>
</dl>
<p><b>Qualifier 2: Library</b>
</p>
<dl>
<dt><b><u>*LIBL</u></b></dt>
<dd>All libraries in the job's library list are searched until the first match is found.
</dd>
<dt><b>*CURLIB</b></dt>
<dd>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.
</dd>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the library to be searched.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.OUTMBR"></a>
<h3>Output member options (OUTMBR)</h3>
<p>Specifies the database file member to which the output is directed.
</p>
<p><b>Element 1: Member</b>
</p>
<dl>
<dt><b><u>*FIRST</u></b></dt>
<dd>The first member in the file receives the output.
</dd>
</dl>
<p><b>Element 2: Replace or add records</b>
</p>
<dl>
<dt><b><u>*REPLACE</u></b></dt>
<dd>The file is cleared before new records are inserted.
</dd>
<dt><b>*ADD</b></dt>
<dd>New records are added after any existing records.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.DATETIME"></a>
<h3>Date and time (DATETIME)</h3>
<p>Specifies whether the system date and time are printed on the bottom of each page.
</p>
<dl>
<dt><b><u>*YES</u></b></dt>
<dd>The system date and time are printed on the bottom of each page.
</dd>
<dt><b>*NO</b></dt>
<dd>The system date and time are not printed on the bottom of each page.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.PAGNBR"></a>
<h3>Page numbers (PAGNBR)</h3>
<p>Specifies whether page numbers are printed on the bottom of each page.
</p>
<dl>
<dt><b><u>*YES</u></b></dt>
<dd>The page numbers are printed on the bottom of each page.
</dd>
<dt><b>*NO</b></dt>
<dd>The page numbers are not printed.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.RDB"></a>
<h3>Relational database (RDB)</h3>
<p>Specifies the relational database that is accessed during the processing of this command.
</p>
<dl>
<dt><b><u>*NONE</u></b></dt>
<dd>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.
</dd>
<dt><b>*CURRENT</b></dt>
<dd>The relational database to which you are currently connected is accessed.
<p>With *RUW connection management, if the user is connected to a remote database, *OUTFILE cannot be specified on the OUPUT parameter.
</p>
<p>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.
</p>
</dd>
</dl>
<dl>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the relational database that is accessed. The database you specify must have an entry in the relational database directory.
<p>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.
</p>
<p>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.
</p>
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.RDBCNNMTH"></a>
<h3>Connection Method (RDBCNNMTH)</h3>
<p>Specifies the connection method to use.
</p>
<dl>
<dt><b><u>*DUW</u></b></dt>
<dd>Connections to several relational databases are allowed. Consecutive CONNECT statements to additional relational databases do not result in the disconnection of previous connections.
</dd>
<dt><b>*RUW</b></dt>
<dd>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.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.USER"></a>
<h3>User (USER)</h3>
<p>Specifies the user name sent to the remote system when starting the conversation.
</p>
<dl>
<dt><b><u>*CURRENT</u></b></dt>
<dd>The user name associated with the current job is used.
</dd>
<dt><b><i>name</i></b></dt>
<dd>Specify the user name being used for the application requester job.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.PASSWORD"></a>
<h3>Password (PASSWORD)</h3>
<p>Specifies the password to be used on the remote system.
</p>
<dl>
<dt><b><u>*NONE</u></b></dt>
<dd>No password is sent. The user name specified on the USER parameter is not valid if this value is specified.
</dd>
<dt><b><i>character-value</i></b></dt>
<dd>Specify the password of the user name specified on the USER parameter.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.NAMING"></a>
<h3>Naming convention (NAMING)</h3>
<p>Specifies the naming convention used for naming objects.
</p>
<dl>
<dt><b><u>*SYS</u></b></dt>
<dd>The system naming convention is used (database-name/object-name).
</dd>
<dt><b>*SQL</b></dt>
<dd>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.
</dd>
<dt><b>*SAA</b></dt>
<dd>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.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.ALWQRYDFN"></a>
<h3>Allow information from QRYDFN (ALWQRYDFN)</h3>
<p>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.
</p>
<dl>
<dt><b><u>*NO</u></b></dt>
<dd>Information is not taken from a QRYDFN object.
</dd>
<dt><b>*YES</b></dt>
<dd>Information is taken from a QRYDFN object when the specified QMQRY or QMFORM object name is not found.
</dd>
<dt><b>*ONLY</b></dt>
<dd>Information is taken only from a QRYDFN object. Query management objects are ignored.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="STRQMQRY.SETVAR"></a>
<h3>Set variables (SETVAR)</h3>
<p>Specifies the variables that are set by query management before the query is run. Up to 50 variables can be set.
</p>
<p><b>Element 1: Variable name</b>
</p>
<dl>
<dt><b><i>character-value</i></b></dt>
<dd>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.
</dd>
</dl>
<p><b>Element 2: Variable value</b>
</p>
<dl>
<dt><b><i>character-value</i></b></dt>
<dd>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.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div><h3><a name="STRQMQRY.COMMAND.EXAMPLES">Examples</a> </h3>
<p><b>Example 1: Displaying Query Output</b>
</p>
<p>
<pre>
STRQMQRY QMQRY(MYLIB/MYQRY) QMFORM(FORM1)
</pre>
</p>
<p>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.
</p>
<p><b>Example 2: Taking Information From Either QMQRY or QRYDFN</b>
</p>
<p>
<pre>
STRQMQRY QMQRY(MYLIB/MYQRY) QMFORM(FORM1) ALWQRYDFN(*YES)
</pre>
</p>
<p>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.
</p>
<p><b>Example 3: Printing Query Output</b>
</p>
<p>
<pre>
STRQMQRY QMQRY(MYLIB/QUERY1) OUTTYPE(*PRINTER)
</pre>
</p>
<p>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.
</p>
<p><b>Example 4: Sending Output to an Existing File</b>
</p>
<p>
<pre>
STRQMQRY QMQRY(*CURLIB/MYQRY)
OUTPUT(*OUTFILE) OUTFILE(MYTAB) OUTMBR(*FIRST *ADD)
</pre>
</p>
<p>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.
</p>
<p><b>Example 5: Running a Query Containing Substitution Variables</b>
</p>
<p>
<pre>
STRQMQRY QMQRY(MYQUERY)
SETVAR((VAR1 'select * from mytable')
(VAR2 'where salary &gt; 15000'))
</pre>
</p>
<p>This command runs query MYQUERY, which contains only substitution variables, &amp;VAR1 and &amp;VAR2. These two variables contain the entire structured query language (SQL) statement.
</p>
<p><b>Example 6: Changing a Variable</b>
</p>
<p>
<pre>
STRQMQRY QMQRY(QRYNAME) SETVAR((LASTNAME '''Smith'''))
</pre>
</p>
<p>This command runs query QRYNAME, setting the variable LASTNAME to the value, 'Smith'.
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div><h3><a name="STRQMQRY.ERROR.MESSAGES">Error messages</a> </h3>
<p><b><u>*ESCAPE Messages</u></b>
</p>
<dl>
<dt><b>QWM2701</b></dt>
<dd>&amp;1 command failed.
</dd>
<dt><b>QWM2703</b></dt>
<dd>&amp;1 command ended.
</dd>
<dt><b>QWM2707</b></dt>
<dd>*LIBL not allowed when SQL naming applied.
</dd>
<dt><b>QWM2709</b></dt>
<dd>User or password not valid with relational database value.
</dd>
<dt><b>QWM2710</b></dt>
<dd>Password value *NONE only valid with user value *CURRENT.
</dd>
<dt><b>QWM2712</b></dt>
<dd>Character in user name not valid.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#STRQMQRY.Top_Of_Page">Top</a></td></tr>
</table>
</body>
</html>