← Back to Stormify Documentation

transaction

suspend fun <R> transaction(block: suspend () -> R): R

Execute block inside a transaction. Commits on success, rolls back on any throwable.

Failures surface as onl.ycode.kdbc.SQLException with the original throwable as cause — the same contract as blocking Stormify.transaction. Coroutine cancellation is exempt and always propagates unwrapped.

If called from inside another transaction { } on the same SuspendStormify, opens a savepoint on the ambient connection. If called from inside a bare withConnection { }, runs a full BEGIN/COMMIT cycle on that connection. While the block runs, convenience operations on the underlying Stormify transparently route through this transaction's connection.