Treatment executeEach

sql::executeEach


Configuration

⬡ sql_pool: sql::SqlPool

Parameters

↳ var bind_symbol: string = "?"
↳ var bindings: Vec<string>
↳ var sql: string
↳ var stop_on_failure: bool = true

Inputs

⇥ bind: Stream<Map> (std/data/map::Map)

Outputs

↦ affected: Stream<u64>
↦ completed: Block<void>
↦ errors: Stream<string>
↦ failed: Block<void>
↦ finished: Block<void>


Execute a parameterised SQL statement once per incoming binding map.

Each Map received on bind triggers one execution of sql. affected emits the row count for each successful execution. When stop_on_failure is true (the default), the stream stops at the first error and failed is emitted; otherwise all maps are processed and errors are streamed through errors. completed or failed is emitted when the stream ends; finished is always emitted.

graph LR
     T("executeEach()")
     B["🟦 🟦 🟦 …"] -->|bind| T
     T -->|affected| A["🟨 🟨 🟨 …"]
     T -->|completed| C["〈🟩〉"]
     T -->|failed| F["〈🟥〉"]
     T -->|errors| E["🟫 …"]
     T -->|finished| FN["〈🟦〉"]
     style B fill:#ffff,stroke:#ffff
     style A fill:#ffff,stroke:#ffff
     style C fill:#ffff,stroke:#ffff
     style F fill:#ffff,stroke:#ffff
     style E fill:#ffff,stroke:#ffff
     style FN fill:#ffff,stroke:#ffff