Issue the INSERT statement to insert new rows into a table. You can define as many rows per table as you need.
Keep this information in mind when using the INSERT statement:
Use this syntax in an AOF rule or an OPS/REXX program:
ADDRESS SQL "INSERT keywords"
{INTO}
[(columnlist)]
/* The following keywords are mutually exclusive: */
[VALUES(valuelist)]
[QUERY STATEMENT]
/* Place these keywords at the end of the command if you use them: */
[SYSTEM(ALL|EXT|sysnames)]
[SYSWAIT(seconds)]
[OUTPUT|NOOUTPUT]
[SYSPLEX]
Use this syntax to invoke the statement from a TSO terminal, a TSO/E REXX program, or a TSO CLIST:
OPSQL INSERT
/* Specify these required keywords in the order shown: */
{INTO}
{tablename}
/* Optional keywords */
[(columnlist)]
/* The following keywords are mutually exclusive: */
[VALUES(valuelist)]
[QUERY STATEMENT]
You may specify these operands for the INSERT statement:
Defines the table to which you are adding rows.
(Optional) Defines the column names that store the values specified with the valuelist operand. If you specify no columnlist, SQL stores the values into the columns in the order in which they were defined on the CREATE TABLE statement for this table.
(Optional) Defines the column values for the new row. A value can be any of the following:
(Optional) Retrieves the values to be inserted into the table. This can be any valid search criteria. See the chapter “Using the Relational Data Framework” in the User Guide.
(Optional) Performs cross-system SQL operations. Specify one of these values:
Routes the SQL command to all active MSF-defined systems, including the local system.
Routes the SQL command to all remote, active MSF-defined systems.
Routes the SQL command to the specified systems. You may specify from one to eight system names as the value of sysnames.
For more information, see the chapter “Using the Relational Data Framework” in the User Guide.
(Optional) Defines the number of seconds the SQL processor waits for output from a remote system. You may specify a value between 1 and 300 seconds.
Do not specify a value for SYSWAIT if you specify the SYSTEM(ALL), SYSTEM(EXT), or NOOUTPUT keywords.
(Optional) Indicates whether the command returns output to the external data queue. Specify OUTPUT to have output returned; otherwise, specify NOOUTPUT.
NOOUTPUT is implied when:
(Optional) Reduces the scope of the SYSTEM(ALL|EXT) operand to MSF connected systems that belong to the same z/OS sysplex as the command issuer. The keyword has no effect on a list of explicit system names.
Examples: Using the INSERT statement
These examples illustrate the use of the INSERT statement:
When your table contains many columns but you need to set values for only a few columns initially, you can insert values into selected columns. When specifying column values with the VALUES clause, specify them in the same order you used to specify columns in the column list. The following sample statement, invoked by OPS/REXX, inserts a row into the SYSTEMS table. This row will have the values CICS1 and DOWN in the NAME and CURRENT_STATE columns respectively:
ADDRESS SQL
"INSERT INTO SYSTEMS (NAME, CURRENT_STATE) VALUES ('CICS1' 'DOWN')"
You also can specify values through host variables. For example, to insert a job name value into a row of the SYSTEMS table, you could use the variable JOBNAME in an AOF rule as follows:
JOBNAME = MSG.JOBNAME ADDRESS SQL "INSERT INTO SYSTEMS (NAME) VALUES (:JOBNAME)"
Suppose that you have two tables. The APPLICATIONS table contains four columns: APPL_ID, USER_ID, UPDATE, and STATUS. The structure of the NEWAPPS table is identical to that of the APPLICATIONS table. You might want to add a row to the APPLICATIONS table for each of the new applications that have been altered by a certain three users. In this case, you could substitute the VALUES clause with a query statement and invoke your INSERT statement from a TSO CLIST as follows:
OPSQL INSERT INTO APPLICATIONS SELECT * FROM NEWAPPS +
WHERE USER_ID IN ('TSOUSR1','TSOUSR2','TSOUSR3')
| Copyright © 2012 CA. All rights reserved. | Tell Technical Publications how we can improve this information |