skip to main content

Embedded SQL Statements : UPDATE

UPDATE
The UPDATE statement replaces the values of the specified columns with the values of the specified expressions for all rows of the table that satisfy the search condition.
General format
EXEC SQL [AT Database]
  UPDATE Options SET { Column-Name = Column-Value } ...
         [ WHERE {Search-Condition      } ]
Syntax rules
1.
Options is passed to the driver without further checks. Refer to the database documentation for detailed syntax. Syntax errors, if any, are returned at runtime.
2.
Column-Name is a User-defined word, as defined in the Definitions section of the Preface of this document.
3.
Column-Value is a host variable or a Nonnumeric Literal, as defined in the Definitions section of the Preface of this document.
General rules
1.
When Search-Condition is specified, only values in rows matching it are replaced.
2.
When Search-Condition is not specified, values of all rows are replaced.
3.
When Host-Variable is a host variable declared as a group-item, the runtime can use all subordinate items as separate values instead of using the group-item as a single value. To enable this feature, compile with the -cghv option.
4.
Database identifies the active connection that will execute the query and must be previously defined using a Format 4 DECLARE statement.
Examples
Apply a discount to customers meeting a criteria
exec sql
     update customers
        set discount = 0.10

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left