UPDATE (Searched)

Updates a table or view based on specified search conditions.


>>--EXEC SQL--.-------------------.---------------------->
              +-FOR :host_integer-+ 

       +-AT db_name--+                  +-view_name--+

          +------ ,--------+
          V                |
                             +-WHERE search_conditions-+



:host_integer A host variable that specifies the maximum number of host array elements processed. Must be declared as PIC S9(4) COMP-5 or PIC S9(9) COMP-5.
db_name The name of a database that has been declared using DECLARE DATABASE.
table_name The table to be updated.
view_name The view to be updated.
column_expression A value for a particular column name. This value can be an expression or a null value.
search_conditions Any valid expression that can follow the standard SQL WHERE clause.


UPDATE is a standard SQL statement which is passed directly to the ODBC driver. See the documentation supplied with your ODBC driver for the exact syntax.

If you do not specify a WHERE clause, all the rows in the named table are updated.

If one of the host variables used in the WHERE clause or SET clause is an array, they must all be arrays.

After execution, SQLERRD(3) contains the number of elements processed. For UPDATE it is the total number of rows updated.


        UPDATE staff
        SET first_name = 'Jonathan'
        WHERE staff_id = 1

     MOVE 'Phil' TO NewName
     MOVE 1 TO targetID

        UPDATE staff
        SET first_name = :NewName
        WHERE staff_id  = :targetID