batch

fun batch(sql: String, bindArgs: Sequence<Array<out Any?>>): Int

Transacts to the database in exclusive mode a batch of queries with the same underlying SQL statement. The prototypical use case is for database modifications inside a tight loop to which this is optimised.

Each array in the sequence must have the same length, corresponding to the number of arguments in the SQL statement. It is safe for the sequence to recycle the array with each yield.

The transaction is not committed by this method until the sequence ends. For long sequences you may therefore wish to yield the transaction periodically.

Return

the number of rows affected.

Parameters

sql

statement with ? placeholders for bind parameters.

bindArgs

sequence of standard type arguments for binding to the statement.


fun batch(sql: String, bindArgs: Iterable<Array<out Any?>>): Int

Transacts to the database in exclusive mode a batch of queries with the same underlying SQL statement. The prototypical use case is for database modifications inside a tight loop to which this is optimised.

Each array in the iterable must have the same length, corresponding to the number of arguments in the SQL statement. It is safe for the iterable to recycle the array with each step.

The transaction is not committed by this method until the iterable is exhausted. For long iterations you may therefore wish to yield the transaction periodically.

Return

the number of rows affected.

Parameters

sql

statement with ? placeholders for bind parameters.

bindArgs

iterable of standard type arguments for binding to the statement.


fun batch(sql: String, bindArgs: Stream<Array<out Any?>>): Int

Transacts to the database in exclusive mode a batch of queries with the same underlying SQL statement. The prototypical use case is for database modifications inside a tight loop to which this is optimised.

Each array from the stream must have the same length, corresponding to the number of arguments in the SQL statement. It is safe for the stream to recycle the array with each step.

The transaction is not committed by this method until the stream is exhausted. For long transactions you may therefore wish to yield periodically.

Return

the number of rows affected.

Parameters

sql

statement with ? placeholders for bind parameters.

bindArgs

stream of standard type arguments for binding to the statement.