StepBuilder
Turns a query into a step instead of running it.
The terminals here are the ones that make sense for something whose result is stored and referred to later: the fetch* family and update. The forEach* family is absent on purpose - a plan keeps every result so that later steps can use it, and a walk over rows too large to hold has nothing to keep. So is RawQuery.execute, reachable though it is on a raw query: it speaks a protocol that binds nothing, so a step made of one could take no TransactionValue and could therefore refer to no earlier step, which is the only thing a step does that a lambda does not. DDL and SET belong in a query run on the transaction's own session; the timeouts worth setting are properties of TransactionDefinition already.
Parameters may hold TransactionValues among ordinary values, and only those are resolved. A SpreadParameters goes among them too, and fills its slot with a row's worth of parameters rather than with one.
val edictId = plan.add(
db.insertInto("edicts").values(edict).returning("id")
.asStep().fetchFieldStrict<Int>(edict)
)
for (item in levy) {
plan.add(
db.insertInto("edict_items").values(listOf("edict_id", "province_id", "amount"))
.asStep().update(
"edict_id" to edictId.value(),
"province_id" to item.provinceId,
"amount" to item.amount
)
)
}Functions
A step that returns the first column of one row as T.
A step that returns the first column of every row as T.
As fetchField, but the step's query must return exactly one row.
A step that maps one row onto T, or null where none matched.
A step that maps every row onto T.
A step that maps one row onto T and fails where the count was anything but one.
A step that returns one row and fails where the count was anything but one.