fetchRows method
Fetch rows as a stream
Implementation
Stream<Map<String, dynamic>> fetchRows() async* {
_ensureNotDisposed();
final columnNames = await _getColumnNames();
while (true) {
// Fetch next row using pre-allocated buffers
final fetchResult = _dpiOracle.dpiStmt_fetch(_statement, _foundPtr, _bufferRowIndex);
if (fetchResult == DPI_FAILURE) {
final errorInfo = _memoryManager.allocate<dpiErrorInfo>(sizeOf<dpiErrorInfo>());
_dpiOracle.dpiContext_getError(_context, errorInfo);
final errorMsg = StringUtils.fromNativeUtf8(errorInfo.ref.message.cast<Char>());
throw OracleResultSetException(
'Failed to fetch row',
errorMessage: errorMsg,
);
}
// Check if no more rows
if (_foundPtr.value == 0) {
break;
}
// Build row map
final row = <String, dynamic>{};
for (var i = 1; i <= _columnCount; i++) {
final columnName = columnNames[i - 1];
final oracleType = _columnOracleTypes![i - 1];
final value = await _getColumnValue(i, oracleType);
row[columnName] = value;
}
yield row;
}
}