QueryResult class

Represents the result of a SQL query execution.

Contains the column names, row data, and row count. Each row is a list of dynamic values corresponding to the columns in the same order.

Example:

final result = QueryResult(
  columns: ['id', 'name', 'age'],
  rows: [
    [1, 'Alice', 30],
    [2, 'Bob', 25],
  ],
  rowCount: 2,
);
Available extensions

Constructors

QueryResult({required List<String> columns, required List<List> rows, required int rowCount, List outputParamValues = const <dynamic>[], List<QueryResult> refCursorResults = const <QueryResult>[], List<DirectedMultiItem> additionalResults = const <DirectedMultiItem>[], List<ColumnMetadata>? columnsMetadata})
Creates a new QueryResult instance.
const

Properties

additionalResults List<DirectedMultiItem>
Additional result sets and row-counts returned by a directed OUT call when the stored procedure / batch produced more than one ODBC result after SQLMoreResults (the MULT envelope path).
final
columns List<String>
Column names in the order they appear in the query result.
final
columnsMetadata List<ColumnMetadata>?
Optional rich metadata per column (name + protocol type discriminant). Populated when the result came through the binary protocol parser; remains null for results constructed from streams that don't carry metadata or for tests/ad-hoc callers.
final
firstRowOrNull Map<String, Object?>?

Available on QueryResult, provided by the QueryResultAccess extension

First row as a map, or null when isEmpty.
no setter
hasAdditionalResults bool
True when additionalResults is non-empty.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasOutputParamValues bool
True when outputParamValues is non-empty.
no setter
hasRefCursorResults bool
True when refCursorResults is non-empty.
no setter
isEmpty bool
Returns true if the result set contains no rows.
no setter
isNotEmpty bool
Returns true if the result set contains at least one row.
no setter
outputParamValues List
Values for OUT / INOUT parameters, when a directed (DRT1) execute is used and the engine appends the OUT1 footer. Empty when the query used only INPUT parameters or a legacy v0 parameter buffer. Entries are typically the sealed ParamValue types from the package's param_value protocol — scalar OUT/INOUT only (no ParamValueRefCursorOut); see doc/notes/TYPE_MAPPING.md §3.1.1.
final
refCursorResults List<QueryResult>
When the native RC1\0 trailer is present, each entry is a full result set materialized from a SYS_REFCURSOR (or similar) OUT parameter.
final
rowCount int
Total number of rows in the result set.
final
rows List<List>
Row data as a list of lists, where each inner list represents one row.
final
rowsAsMaps List<Map<String, Object?>>

Available on QueryResult, provided by the QueryResultAccess extension

All rows as name → value maps aligned with columns.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cell(int row, String column, {bool ignoreCase = false}) Object?

Available on QueryResult, provided by the QueryResultAccess extension

Returns the value at row / column, or null when out of range.
cellAs<T>(int row, String column, {bool ignoreCase = false}) → T?

Available on QueryResult, provided by the QueryResultAccess extension

Returns the value at row / column cast to T, or null when absent or not assignable to T.
columnIndex(String column, {bool ignoreCase = false}) int?

Available on QueryResult, provided by the QueryResultAccess extension

Returns the zero-based index of column, or null when absent.
columnValues<T>(String column, {bool ignoreCase = false, bool includeNulls = true}) List<T?>

Available on QueryResult, provided by the QueryResultAccess extension

Returns all values for column as a typed list.
firstValue<T>(String column, {bool ignoreCase = false}) → T?

Available on QueryResult, provided by the QueryResultAccess extension

Returns the first row's value for column, or null when empty.
hasColumn(String column, {bool ignoreCase = false}) bool

Available on QueryResult, provided by the QueryResultAccess extension

Returns true when column exists in columns.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rowAsMap(int row) Map<String, Object?>

Available on QueryResult, provided by the QueryResultAccess extension

Returns row row as a name → value map aligned with columns.
scalar<T>(String column, {bool ignoreCase = false}) → T?

Available on QueryResult, provided by the QueryResultAccess extension

Single scalar from the first row for column, or null when empty or not assignable to T. Alias for firstValue.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited