DB Script node
The DB Script node runs one or more SQL statements against a database connection as a step in the flow. It's the imperative counterpart to the Load node's declarative "here are rows, write them to this table": DB Script lets you run DDL, cleanup, TRUNCATE, or a stored-procedure call as part of the workflow.
When to use
- You need to run DDL as part of the flow (create a staging table, drop an outdated view, add an index).
- You want a targeted cleanup step (DELETE from a staging area, TRUNCATE a queue table) between a Source and a Load.
- You need to call a stored procedure that itself does the load, and just want to trigger it from the flow.
Ports
| Port | Direction | Kind | Notes |
|---|---|---|---|
in | in | data | Optional. When rows flow in, {{ row.column }} tokens in the script are substituted per row. |
out | out | data | The input rows (or a summary row when emitStatementResults is on) after the script ran. |
error | out | control | Fires on SQL error. |
notify | out | control | Notification policy port. |
Configuration
- Connection. A database connection (SQL Server, PostgreSQL, MySQL, Oracle, Snowflake). File / API / Salesforce connections are not eligible.
- Script. One or more SQL statements separated by
;. The Configure modal's editor is Monaco with per-dialect IntelliSense. - Substitutions. Tokens
{{ row.column }},{{ exec.variable }}, and{{ sys.runId }}are substituted before send. - Static hazard scan. The Validate button surfaces
DROP without IF EXISTS,TRUNCATE TABLE, andDELETE without WHEREas warnings. The server enforces the same rules on/api/db-script/validateso a scripted caller cannot bypass. - Emit statement results. When on, each statement's result set becomes an output row.
Configure Action walkthrough
- Connection — pick a DB-family connection. The dialect drives Monaco's language mode and the hazard scanner.
- Script — write the statements. Save runs Validate automatically.
- Validate — hazards render as chips with the offending statement index. Warnings don't block Save; you decide.
- Preview — optional, runs the first statement against the live connection with a small sample.
Runtime behaviour
- Statements run in order in a single connection. A failure mid-script routes to
errorwith the failed statement index and the DB message. - When rows are flowing in,
{{ row.X }}substitutions run per row — one script execution per row. Cross-row bulk substitution is not supported; use Load for that. - The static hazards are advisory. The runtime does NOT block a
DELETE without WHERE— the operator sees the warning and decides.
Failure modes
- DB error. The
errorport gets the SQL state, error number, statement index, and message. - Substitution failure. A missing
{{ row.X }}renders as empty. Cast columns explicitly in the script if a null would produce an invalid statement. - Timeout. The connection's default statement timeout applies; override on the connection config, not on the node.