Previous Topic: FETCH Statement—Retrieve Row ValuesNext Topic: OPEN Statement—Initiate Cursor Operation


INSERT Statement—Insert Table Rows

The INSERT statement lets you insert new rows into a table. You can define as many rows per table as you need.

Consider the following information when you use 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]
[SUBSYS(subsystem)]

To invoke the statement from a TSO terminal, a TSO/E REXX program, or a TSO CLIST, use this syntax:

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]

Specify these operands for the INSERT statement:

tablename

Defines the table to which you add rows.

columnlist

(Optional) Defines the column names that store the values that you specify 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.

valuelist

(Optional) Defines the column values for the new row. A column can have any of the following values:

QUERY STATEMENT

(Optional) Retrieves the values to be inserted into the table. This value can be any valid search criteria. See the chapter “Using the Relational Data Framework” in the User Guide.

SYSTEM

(Optional) Performs cross-system SQL operations. Specify one of these values:

ALL

Routes the SQL command to all active MSF-defined systems, including the local system.

EXT

Routes the SQL command to all remote, active MSF-defined systems.

sysnames

Routes the SQL command to the specified systems. You may specify from one to eight system names as the value of sysnames.

Note: For more information, see the chapter “Using the Relational Data Framework” in the User Guide.

SYSWAIT

(Optional) Defines the number of seconds the SQL processor waits for output from a remote system.

Limits: 1-300 seconds

Do not specify a value for SYSWAIT if you specify the SYSTEM(ALL), SYSTEM(EXT), or NOOUTPUT keywords.

OUTPUT or NOOUTPUT

(Optional) Indicates whether the command returns output to the external data queue. To return output, specify OUTPUT; otherwise, specify NOOUTPUT.

NOOUTPUT is implied when:

SYSPLEX

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

SUBSYS

(Optional) Performs SQL operations on other CA OPS/MVS subsystems that are in communication with the current one. Specify the following value:

subsystem

Routes the SQL command to the specified subsystem. You can use only one four-character name of the subsystem as follows: OPSx.

Examples: Using the INSERT statement

These examples illustrate the use of the INSERT statement: