forEachRow

fun forEachRow(params: Map<String, Any?>, fetchSize: Int, block: (Row) -> Unit)

Streams the result, handing each row to block as it arrives.

Rows reach block one at a time and none are kept, so memory stays flat however large the result is; fetchSize governs the other side of it - how many rows the server sends before pausing for the next batch, or the whole result at once under 0. The whole iteration is one running statement: statement_timeout covers time spent inside block, and block must not issue another query on this same session.

Parameters

params

Values by parameter name, without the leading @.

fetchSize

Rows per batch, or 0 for the whole result in one. Required — there is no default.

block

Invoked once per row, on the calling thread.

Throws

CONVERSION_ERROR wrapping anything block throws that is not an OctaviusException, since the result has to be drained before it can be rethrown.


fun forEachRow(vararg params: Pair<String, Any?>, fetchSize: Int, block: (Row) -> Unit)

Same as forEachRow, with the values given as Pairs.