streamBatches method

Stream<List<Map<String, Object?>>> streamBatches(
  1. String sql, {
  2. Object parameters = const <String, Object?>{},
  3. MssqlQueryOptions options = MssqlQueryOptions.defaults,
  4. Duration? timeout,
  5. MssqlCancellationToken? cancellationToken,
  6. int? batchRows,
  7. int? maximumRows,
  8. int? maximumBytes,
})
inherited

Batches of maps from a single row-producing result set.

Implementation

Stream<List<Map<String, Object?>>> streamBatches(
  String sql, {
  Object parameters = const <String, Object?>{},
  MssqlQueryOptions options = MssqlQueryOptions.defaults,
  Duration? timeout,
  MssqlCancellationToken? cancellationToken,
  int? batchRows,
  int? maximumRows,
  int? maximumBytes,
}) async* {
  var resultSets = 0;
  await for (final event in stream(
    sql,
    parameters: parameters,
    options: options,
    timeout: timeout,
    cancellationToken: cancellationToken,
    batchRows: batchRows,
    maximumRows: maximumRows,
    maximumBytes: maximumBytes,
  )) {
    if (event is MssqlResultSetStart && ++resultSets > 1) {
      throw const MssqlException(
        type: MssqlErrorType.protocol,
        message: 'streamBatches supports one row-producing result set.',
      );
    }
    if (event is MssqlRowBatch) {
      yield event.rows.map((row) => row.toMap()).toList(growable: false);
    }
  }
}