DB Query
DB Query
Section titled “DB Query”Type: db-query · Package: Database Activities v1.0.0 · Output: DataTable
Runs a SELECT query and returns the results as a DataTable, ready to traverse, filter, or dump to Excel. It is the most common reading activity.
How it works
Section titled “How it works”Runs SELECT over the connection and returns its rows in a DataTable, with one column for each column of the result. Uses parameters @nombre and field params for variable values (see parameterized queries).
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
sql | expression | The SELECT statement. 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 DataTable. Loop through it with For Each and access cells with str(row["Columna"]).
Example
Section titled “Example”DB Query sql = "SELECT Id, Nombre, Saldo FROM Clientes WHERE Ciudad = @ciudad" params = { "ciudad": = ciudadBuscada } → output: clientes
Log message = = "Clientes encontrados: " + rowCount(clientes)For Each items = = clientes itemVariable = fila └─ activities: Log message = = str(row["Nombre"]) + ": " + num(fila["Saldo"])Related activities
Section titled “Related activities”- DB Scalar — when the SELECT returns a single value.
- DB Execute — for INSERT/UPDATE/DELETE.
- DataTable — filter, sort and summarize the result.