abstract class DB::ResultSet
- DB::ResultSet
- Reference
- Object
Overview
The response of a query performed on a Database
.
See DB
for a complete sample.
Each #read
call consumes the result and moves to the next column.
Each column must be read in order.
At any moment a #move_next
can be invoked, meaning to skip the
remaining, or even all the columns, in the current row.
Also it is not mandatory to consume the whole ResultSet
, hence an iteration
through #each
or #move_next
can be stopped.
Note: depending on how the ResultSet
was obtained it might be mandatory an
explicit call to #close
. Check QueryMethods#query
.
Note to implementors
- Override
#move_next
to move to the next row. - Override
#read
returning the next value in the row. - (Optional) Override
#read(t)
for some typest
for which custom logic other than a simple cast is needed. - Override
#column_count
,#column_name
.
Included Modules
Defined in:
db/result_set.crConstructors
Instance Method Summary
-
#column_count : Int32
Returns the number of columns in the result
-
#column_name(index : Int32) : String
Returns the name of the column in
index
0-based position. -
#column_names
Returns the name of the columns.
-
#each(&block)
Iterates over all the rows
-
#each_column(&block)
Iterates over all the columns
-
#move_next : Bool
Move the next row in the result.
-
#read(type : DB::Mappable.class)
Reads the next columns and maps them to a class
-
#read(type : T.class) : T forall T
Reads the next column value as a type
-
#read
Reads the next columns and returns a named tuple of the values.
-
#read
Reads the next column value
-
#read(*types : Class)
Reads the next columns and returns a tuple of the values.
Constructor Detail
Instance Method Detail
Returns the name of the column in index
0-based position.