RUN command

The RUN command runs procedures, queries, indexes, or dynamarts that are stored in a database or are current objects in an open window (reside in temporary storage). For queries, the RUN command provides the ability to save the retrieved results to a database.

Syntax

To run an object that resides on the database:

>>-- RUN ----------- ObjectName -------------------------------------------------------<<
         +- QUERY -+            ( +- &&Variable = Value -----------------------------+
                                  +- ACCELERATOR = acceleratorname ------------------+
                                  +- ACCELERATORDATABASE = databasename -------------+
                                  +- ACTION = REPLACE/APPEND ------------------------+
                                  +- COMMENT = text ---------------------------------+
                                  +- CONFIRM = YES/NO -------------------------------+
                                  +- FORM = FORM/formname----------------------------+
                                  +- METHOD = REGULAR/FAST/FASTSAFE------------------+
                                  +- MODE = GRID/RAW --------------------------------+
                                  +- ROWIDADD = YES/NO ------------------------------+
                                  +- ROWIDDISP = EXCLUDE/CONVERT/ALWAYS/BYDEFAULT----+
                                  +- ROWIDNAME = text -------------------------------+
                                  +- ROWLIMIT = NumRows------------------------------+
                                  +- SCOPE = NumChars -------------------------------+
                                  +- SPACE = tablespace/database.tablespace----------+
                                  +- SPACE DATABASE = database-----------------------+
                                  +- TABLE = name/owner.name-------------------------+
Note: You can run indexes only if you are connected to Cloudant data sources.
>>-- RUN ---------- ObjectName -------------------------------------<<
         +- PROC -+               ( + &&Variable = Value ----------+
>>-- RUN -------------- ObjectName ----------------------------------<<
         +- DYNAMART -+            ( +- &&Variable = Value --------+
                                     +- CONFIRM = YES/NO ----------+
                                     +- REFRESH = YES/NO ----------+
                                     +- ROWLIMIT = NumRows --------+

To run an object from an open window (temporary storage):

>>-- RUN QUERY -------------------------------------------------------<<
               ( +- &&Variable = Value -----------------------------+
                 +- ACCELERATOR = acceleratorname ------------------+
                 +- ACCELERATORDATABASE = databasename -------------+
                 +- ACTION = REPLACE/APPEND ------------------------+
                 +- COMMENT = text ---------------------------------+
                 +- CONFIRM = YES/NO -------------------------------+
                 +- FORM = FORM/formname ---------------------------+
                 +- METHOD = REGULAR/FAST/FASTSAFE------------------+
                 +- MODE = GRID/RAW --------------------------------+
                 +- ROWIDADD = YES/NO ------------------------------+
                 +- ROWIDDISP = EXCLUDE/CONVERT/ALWAYS/BYDEFAULT----+
                 +- ROWIDNAME = text -------------------------------+
                 +- ROWLIMIT = NumRows/NO --------------------------+
                 +- SCOPE = NumChars -------------------------------+
                 +- SPACE = tablespace/database.tablespace----------+
                 +- SPACE DATABASE = database-----------------------+
                 +- TABLE = name/owner.name-------------------------+
>>-- RUN PROC -----------------------------------------------------<<
               ( +- &&Variable = Value ... ----+
>>-- RUN DYNAMART -------------------------------------------<<
                  ( +- &&Variable = Value --------+
                    +- CONFIRM = YES/NO ----------+
                    +- REFRESH = YES/NO ----------+
                    +- ROWLIMIT = NumRows --------+
Table 1. Parameters for running objects
Parameter Description
&&Variable Assigns a value to a variable in the query, procedure, or dynamart that is run. The variable name can be from 1 to 17 characters long and the value can be from 1 to 55 characters long. You can specify any number of variables and values on the RUN command. If there are variables in the query, procedure, or dynamart that are not given values on the RUN command, and are not global variables, the user will be prompted for the values. When you include variable assignments in a procedure, you must use two ampersands to prevent variable substitution before the procedure is run.
CONFIRM Specifies whether or not to display a confirmation dialog before replacing or changing an object as a result of this command. If CONFIRM is not specified or is NO, the corresponding resource limit is used.
FORM Specifies a form to use when generating a displayed report using the data retrieved by the query. You can specify the keyword FORM to use the current form object, or specify the name of a form saved in the database.
ObjectName The name of the query, procedure, or dynamart to run.
Note: For Cloudant queries, specify the full object key. For Cloudant indexes, specify either the full object key or the design document name and the index name separated by a period (.)
REFRESH Specifies whether or not to refresh data previously saved in a dynamart. If this parameter is set to YES, the dynamart is opened in the Query editor, query is run to refresh data, and then updated data is automatically saved in the dynamart.
ROWLIMIT Specifies the maximum number of rows to retrieve for the query or dynamart.
Table 2. Parameters for saving query results to a database
Parameter Description
ACCELERATOR Specifies the name of the accelerator that you want to use to save your data. The ACCELERATOR keyword can be up to 128 characters long. The ACCELERATOR keyword cannot be specified if the SPACE keyword is already specified for the command, unless the value of the DSQEC_SAV_ALLOWED global variable is set to 5. The default value for the ACCELERATOR keyword is taken from the DSQEC_SAV_ACCELNM global variable.

The ACCELERATOR keyword is supported only on Db2 z/OS servers that support IDAA. The ACCELERATOR keyword is ignored if the TABLE keyword is not specified.

ACCELERATORDATABASE Specifies the name of the accelerator database that you want to use to save your tables. The ACCELERATORDATABASE keyword can be up to 128 characters long. The default value of the ACCELERATORDATABASE parameter is taken from the DSQEC_SAV_ACCELDB global variable. If the DSQEC_SAV_ACCELDB global variable value is not empty, the database specified by the SPACE keyword is ignored. If the ACCELERATORDATABASE parameter value is not empty, the value of the DSQEC_SAV_ACCELDB is ignored.
ACTION Specifies whether to replace the entire database table or append data to the existing table.
  • Specify REPLACE to replace the data in the database table by the query results data.
  • Specify APPEND to add query results to the existing database table.
COMMENT Specifies a comment for the database table to which you save query results. The text of the comment must be enclosed in quotes.
CONFIRM Specifies whether to display a confirmation dialog before replacing or changing an object as a result of this command. If CONFIRM is not specified or is NO, the corresponding resource limit is used.
METHOD Specifies the method of saving the query results data.
  • Specify REGULAR to send query results data from the client back to the database server and insert them into the table.
  • Specify FAST to rerun the query at the server and insert query results directly into the table.
  • Specify FASTSAFE to rerun the query at the server without the ORDER BY clauses and insert query results directly into the table.
MODE Specifies whether the query result data is saved with formatting and added calculated columns.
  • Specify GRID to set that all of the data as it is currently formatted in the current query results will be saved. Any calculated columns that have been added to the query results are included.
  • Specify RAW to set that all of the data in the current query results will be saved. Any formatting that is applied to the data will not be saved. Any calculated columns that are added to the query results will not be saved. This is the default value.
ROWIDADD Specifies whether to add the Row ID column to the table.
ROWIDNAME Specifies the name for the new Row ID column.
ROWIDDISP Specifies the disposition of the new Row ID column.
SCOPE Specifies the commit scope of the data.
SPACE Specifies both the database name and the table space name to save the table in a particular database container and table space.
Note: The table space name that you specify must match the default table space name that is set for your user ID on the Save Data tab of the resource limits settings. If you have the permission to override the default table space name, you can specify any table space name to which you want to save the table. The permission to override the table space name is set on the Save Data tab of the resource limits settings.
Note:
  • database.tablespace is used for Db2® for z/OS databases.
  • tablespace is used for Db2 for LUW databases.
SPACE DATABASE Specifies only the database name to save the table in a particular database container with the table space created automatically under the name of the created table.
Note: The parameter is used only for z/OS databases.
TABLE Specifies the name of the database table to which you want to save query results. If you specify both owner name and table name as a value for this parameter, the table is saved with the specified name for the specified owner. If you specify only the table name, the table is save with the specified name for the owner that runs the procedure.
Note: If you specify the TABLE parameter for your query, the ROWLIMIT parameter is ignored.

Example

The following example runs a query from the QMF Catalog.
RUN QUERY USER1.QUERY1 (&&Var1=10
The following examples run a Cloudant query that is stored in a repository:
RUN rsbi:/.workspaces/Default/Cloudant_query
RUN QUERY rsbi:/.workspaces/Default/Cloudant_query
The following examples run a Cloudant index from a database:
RUN "rsbi:/Cloudant Data Sources/Cloudant/exampleViews/
Secondary Indexes/exampleIndex"
RUN INDEX exampleViews.exampleIndex