The UPDATE action executes an SQL UPDATE statement against a supported database.
Use this action to modify existing records in a MariaDB, PostgreSQL, or Microsoft SQL Server database. Query parameters can be passed separately from the SQL statement using metadata values, allowing data from forms, process variables, and integrations to be used when updating database records. Database queries are executed using prepared statements to support secure parameter handling.
The input parameters of the action are:
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | String | Required | The SQL UPDATE statement to execute against the database. |
| metadata | JSON | Optional | A list of parameters that can be passed into the SQL statement. |
The metadata parameter can be used to pass process variables into the SQL statement. The example metadata:
{
"customerId": "CUST-10025",
"customerStatus": "Active"
}
`
Can be used for the following query:
UPDATE customers
SET status = {customerStatus}
WHERE customer_id = {customerId};
In this example, the values contained in metadata are substituted into the query as prepared statement parameters when the SQL statement is executed.
The output parameters of the action are:
| Parameter | Type | Required | Description |
|---|---|---|---|
| result | Integer | Optional |
The number of database rows affected by the UPDATE statement. If the update modifies one customer record, the output might be: {
"result": 1
}
This indicates that one row in the database was successfully updated. |