IConnectionPool.execTransaction

Performs several SQL commands on single connection wrapped in a transaction (BEGIN/COMMIT in PostgreSQL). Each command should use '$n' notation to refer params values. Before any command occurs in transaction the local SQL variables is set from vars.

argnums array holds information about which parameter from params should be passed to a query in commands. If there are no params, the argnums can be empty.

oneRowConstraint store info which query in commands have to have one row respond. If some query with the constraint switched on returns 0 or greater than 1 - transaction is rollbacked and OneRowConstraintException is thrown.

interface IConnectionPool
InputRange!(immutable Bson)
execTransaction
shared
(
string[] commands
,
string[] params = []
,
uint[] argnums = []
,
string[string] vars = null
,
bool[] oneRowConstraint = []
)
in { assert (commands && params && argnums, "null reference"); assert (argnums.reduce!"a+b" == params.length, "length of params is not equal argument count summ!"); }

Throws

ConnTimeoutException, QueryProcessingException, OneRowConstraintException

Examples

pool.execTransaction(["com1", "com2"],
    ["par1", "par2", "par3"], [1, 2]);
// com1 is fed with par1
// com2 is fed with par2 and par3

Meta