Previous Topic: SELECT Statement

Next Topic: Environment Variables

UPDATE Statement

The UPDATE statement updates values in selected columns in a table. You can use this statement with a cursor.

Syntax

LSQL UPDATE tablename SET colname=value... [WHERE criteria]

Operand

Explanation

colname

The name of the column containing values to be updated.

criteria

The criteria on a WHERE clause can be any valid search criteria. However, when using a cursor, 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. (See the example that follows.)

tablename

The name of the table you are updating.

value

The value that you are inserting into this column. The value can be a character string, numeric string, or host variable.

Note: You can use host variables for colname or tablename.

Examples

Suppose you want to search the APPLICATIONS table for all applications with a status of DOWN and change that status to UP. Issue the following LSQL command:

LSQL UPDATE APPLICATIONS SET STATUS ='UP' WHERE STATUS ='DOWN'

To set the value of the STATUS column to UP for the current row when using a cursor called STATDOWN, issue the following LSQL command:

LSQL UPDATE APPLICATIONS SET STATUS='UP' WHERE CURRENT OF STATDOWN