Previous Topic: Output from the SELECT StatementNext Topic: OPS/REXX Programs


UPDATE Statement—Insert Values

The UPDATE statement lets you insert values into selected columns in a table. The WHERE clause identifies the rows in the table that you want to update. You then specify simple expressions in the SET clause to indicate how you want to update the identified column.

Consider the following information when you use the UPDATE statement:

Note: If you are updating multiple columns, specify a SET clause with multiple colname operands and separate the operands with commas.

Use this syntax in an AOF rule or an OPS/REXX program:

ADDRESS SQL "UPDATE keywords"
{tablename}
{SET colname=string|:hostvar|NULL}
 [WHERE searchcriteria]
[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 UPDATE
{tablename}
{SET colname=string|:hostvar|NULL}
 [WHERE searchcriteria]

Specify these operands for the UPDATE statement:

tablename

Defines the name of the table you want to update.

colname

Defines the name of the column into which you are inserting data. You can specify the colname value as a string, a host variable name, or as NULL. To update multiple columns, include multiple colname clauses in your UPDATE statement, and separate them with commas.

searchcriteria

(Optional) For a searched operation, the criteria on a WHERE clause can be any valid search criteria.

Note: For more information about specifying search criteria, see Searched Operations in the chapter “Using the Relational Data Framework” in the User Guide.

(Optional) For a cursor operation, the criteria on a WHERE clause must include CURRENT OF cursorname, which causes the function to be performed on the current row being processed in the cursorname operation.

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 about cross-system SQL operations, see Notes on Performing Cross-system SQL Operations in 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

Note: 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: UPDATE

These examples illustrate the use of the UPDATE statement: