How to use [data.update]

The reference page of data.update has its arguments, constraints and declaration.

This slot updates rows in your database, using the current open connection created by [data.connect]. It takes the same arguments as [sql.update], and its value resolves to the number of rows affected. Always supply a [where] argument to constrain which rows are updated, since the SQL generated does not constrain the update to any specific row if you leave it out.

  • [table] - Name of the table to update. Mandatory, the slot throws if it is missing
  • [values] - Column names and their new values, as children nodes. Mandatory, the slot throws if it is missing
  • [where] - Condition constraining which rows to update, see the [where] documentation below
  • [database-type] - Database adapter to use instead of your default database type
  • [generate] - If true, only generates the SQL and its parameters instead of executing it, default is false

Below is an example, changing the last name of every actor called John Doe.

data.connect:sakila
   data.update
      table:actor
      values
         last_name:Smith
      where
         and
            first_name:John
            last_name:Doe

// The value of [data.update] becomes the number of records affected.