writeBatch method
Execute a batch of write statements in a single network round-trip wrapped in a transaction for atomicity.
All queries are concatenated with BEGIN TRAN / COMMIT and sent as
one SQL batch via dbcmd + dbsqlexec. This is significantly faster
than sending each statement individually.
Returns a list with one result string per query (the combined result is replicated to preserve the same return shape as the old per-query implementation).
Implementation
Future<List<String>> writeBatch(List<String> queries) async {
await _ensureConnectedOrReconnect();
if (queries.isEmpty) return [];
final batch = <String>[
'BEGIN TRAN',
...queries,
'COMMIT',
];
try {
final result = await _client!.executeBatch(batch);
return List<String>.filled(queries.length, result);
} catch (e) {
try {
await writeData('ROLLBACK');
} catch (_) {}
rethrow;
}
}