DB Execute
DB Execute
Section titled “DB Execute”Type: db-execute · Package: Database Activities v1.0.0 · Output: int
Executes a statement that modifies data—INSERT, UPDATE, or DELETE—and returns the number of rows affected. It is the writing activity in the database: inserting records, updating states, deleting data.
How it works
Section titled “How it works”Executes the statement on the connection and returns how many rows it changed. Uses parameters @nombre and field params for variable values (see parameterized queries).
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
sql | expression | The statement INSERT, UPDATE or DELETE. Use @nombre for parameters. |
Optional parameters
Section titled “Optional parameters”| Parameter | Editor | Description |
|---|---|---|
session | session | DB Connect session. Within a body it is inherited automatically; outside, pass = db. |
params | JSON | Parameter values, as object { nombre: valor }. |
Output
Section titled “Output”Returns a int with the number of rows affected. Useful to verify that the operation impacted what was expected.
Example
Section titled “Example”Mark an order as shipped:
DB Execute sql = "UPDATE Pedidos SET Estado = @estado WHERE Id = @id" params = { "estado": "despachado", "id": = pedidoId } → output: filasAfectadas
If condition = = filasAfectadas == 0 └─ then: Log level = warning message = = "Ningún pedido con id " + pedidoId