startTransaction method

Future<void> startTransaction({
  1. Set<FbTrFlag>? flags,
  2. int? lockTimeout,
})

Starts an explicit transaction.

If an explicit transaction is already pending (has been started but hasn't been ended), this method has no effect (but doesn't throw in such scenario). If flags are not provided, the default connection flags will be used (see FbDb.attach, FbDb.createDatabase and FbOptions).

Example:

final db = await FbDb.attach(host: "localhost", database: "employee");
await db.startTransaction();
// execute statements
await db.commit(); // or db.rollback()
await db.detach();
// db cannot be used any more

Implementation

Future<void> startTransaction({
  Set<FbTrFlag>? flags,
  int? lockTimeout,
}) async {
  await _askWorker(FbDbControlOp.startTransaction, [flags, lockTimeout]);
}