SQL UPDATE Statement

PURPOSE:  This statement changes data in existing rows in a table.  The rows may be part of the current cursor or set.

Syntax

SQL UPDATE designator
   SET str_exp
   [WHERE str_exp, CURRENT ROW]
   [HUSH]

designator

is the name of the table that will be updated.

SET str_exp

is a quoted literal, a character or an alphabetic field, a function, or a concatenation of any of the preceding that evaluates to a string that specifies particular column names and the values to be assigned.  Date expressions require a 2 digit year.  For each column for which you are assigning a value, use this basic format in the string:

     column_name = expression

This string can be built dynamically from within the Process Module.  When more than one column name and value pair are listed, they must be separated by commas.

If the SET clause is not explicitly specified, ACCENT R checks the columns of the current row for changed values.

WHERE str_exp

is a quoted literal, a character or an alphabetic field, a function, or a concatenation of any of the preceding that evaluates to a string that sets the search condition for the rows that are updated.

You can set the string to any valid WHERE clause including column names, expressions, arithmetic operators, comparison operators, the keywords NOT, LIKE, IS NULL, AND, OR, BETWEEN, IN, EXISTS, ANY, ALL, sub-queries, or any combination of these items.  This string can be built dynamically from within the Process Module.  There is no limit on the number of search conditions that can be included.  This search condition cannot contain aggregates.  See the 'WHERE clause' in the Oracle SQL Language Reference Manual for details.

CURRENT ROW

is the row that was last fetched via the SQL FETCH statement.  This clause is mutually exclusive with the WHERE clause.

HUSH

shuts off warning, error, auxiliary, and SQL messages for the execution of that statement only.  The text of the error message can be found in the system function @ERROR_MESSAGE.

Example

SQL SELECT * FROM BOOKS_ORA WHERE "BOOKS_ORA.TITLE_TYPE = 'for_lang'"
START:10
   SQL FETCH NEXT ROW
LEAVE:10 IF @SQLCODE # 0
   'FOREIGN' TO TITLE_TYPE:BOOKS_ORA
   SQL UPDATE BOOKS_ORA CURRENT ROW
REPEAT:10
SQL COMMIT WORK

NOTES:  Oracle does not allow rows of a set established with ORDER BY clause of the SQL SELECT statement or by joining two or more tables to be updated.  The system field @SQLCODE contains the return status of the SQL UPDATE statement.  The system field @SQL_ UPDATE contains the number of rows updated by the SQL UPDATE statement.  Please note that ACCENT R is aware of any columns within the table that change.  Therefore, it is not necessary to specify a SET clause.

SEE ALSO:  OSQL UPDATE command

SQL Select Statement    Syntax Summary