Library: Data
Package: DataCore
Header: Poco/Data/RecordSet.h
RecordSet provides access to data returned from a query. Data access indexes (row and column) are 0-based, as usual in C++.
Recordset provides navigation methods to iterate through the recordset, retrieval methods to extract data, and methods to get metadata (type, etc.) about columns.
To work with a RecordSet, first create a Statement, execute it, and create the RecordSet from the Statement, as follows:
Statement select(session); select << "SELECT * FROM Person"; select.execute(); RecordSet rs(select);
The number of rows in the RecordSet can be limited by specifying a limit for the Statement.
Direct Base Classes: Statement
All Base Classes: Statement
Member Functions: column, columnCount, columnLength, columnName, columnPrecision, columnType, moveFirst, moveLast, moveNext, movePrevious, operator =, operator [], rowCount, value
Inherited Functions: done, execute, extractions, metaColumn, operator <<, operator =, operator,, swap, toString
explicit RecordSet(
const Statement & rStatement
);
Creates the RecordSet.
~RecordSet();
Destroys the RecordSet.
template < class T > const Column < T > & column(
const std::string & name
) const;
Returns the reference to the first Column with the specified name.
template < class T > const Column < T > & column(
std::size_t pos
) const;
Returns the reference to column at specified location.
std::size_t columnCount() const;
Returns the number of rows in the recordset.
std::size_t columnLength(
std::size_t pos
) const;
Returns column maximum length for the column at specified position.
std::size_t columnLength(
const std::string & name
) const;
Returns column maximum length for the column with specified name.
const std::string & columnName(
std::size_t pos
) const;
Returns column name for the column at specified position.
std::size_t columnPrecision(
std::size_t pos
) const;
Returns column precision for the column at specified position. Valid for floating point fields only (zero for other data types).
std::size_t columnPrecision(
const std::string & name
) const;
Returns column precision for the column with specified name. Valid for floating point fields only (zero for other data types).
MetaColumn::ColumnDataType columnType(
std::size_t pos
) const;
Returns the type for the column at specified position.
MetaColumn::ColumnDataType columnType(
const std::string & name
) const;
Returns the type for the column with specified name.
bool moveFirst();
Moves the row cursor to the first row.
Returns true if there is at least one row in the RecordSet, false otherwise.
bool moveLast();
Moves the row cursor to the last row.
Returns true if there is at least one row in the RecordSet, false otherwise.
bool moveNext();
Moves the row cursor to the next row.
Returns true if the row is available, or false if the end of the record set has been reached and no more rows are available.
bool movePrevious();
Moves the row cursor to the previous row.
Returns true if the row is available, or false if there are no more rows available.
Statement & operator = (
const Statement & stmt
);
Assignment operator.
DynamicAny operator[] (
const std::string & name
);
Returns the value in the named column of the current row.
DynamicAny operator[] (
std::size_t index
);
Returns the value in the named column of the current row.
std::size_t rowCount() const;
Returns the number of rows in the recordset.
template < class T > const T & value(
std::size_t col,
std::size_t row
) const;
Returns the reference to data value at [col, row] location.
template < class T > const T & value(
const std::string & name,
std::size_t row
) const;
Returns the reference to data value at named column, row location.
DynamicAny value(
std::size_t col,
std::size_t row
) const;
Returns the reference to data value at column, row location.
DynamicAny value(
const std::string & name,
std::size_t row
) const;
Returns the reference to data value at named column, row location.
DynamicAny value(
const std::string & name
);
Returns the value in the named column of the current row.
DynamicAny value(
std::size_t index
);
Returns the value in the given column of the current row.