discontinuedPackage connect_database has been discontinued.
stream method
Implementation
Future<Result<Stream<Map<String, dynamic>>>> stream() async {
try {
if (!_isConnected) {
await odbc.connect().getOrThrow();
_isConnected = true;
}
var query = commandText;
if (query == null || query.isEmpty) {
return Failure(Exception('CommandText não pode ser vazio.'));
}
if (_useReadUncommitted) {
if (odbc.type == DatabaseType.sqlServer ||
odbc.type == DatabaseType.sybaseAnywhere) {
query = _addNoLock(query);
}
}
if (SqlValidCommand.isSelectQuery(query)) {
if (!_disableInterceptorForStream) {
final interceptedResult =
await _selectInterceptor.interceptSelect(query);
if (interceptedResult.isError()) {
return Failure(interceptedResult.exceptionOrNull()!);
}
query = interceptedResult.getOrThrow();
}
}
final preparedResult = _substituteParameters(query);
if (preparedResult.isError()) {
return Failure(preparedResult.exceptionOrNull()!);
}
final prepared = preparedResult.getOrThrow();
return await odbc.executeCursor(prepared.sql, params: prepared.params);
} catch (e, s) {
return Failure(Exception('Error opening stream: $e\nStack: $s'));
}
}