Class Poco::Data::RecordSet
Author: Applied Informatics Software Engineering GmbH and Contributors
Date: 2009-11-24

# Poco::Data

# class RecordSet

Library: Data
Package: DataCore
Header: Poco/Data/RecordSet.h

## Description

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.

## Inheritance

Direct Base Classes: Statement

All Base Classes: Statement

## Member Summary

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

## Constructors

### RecordSet

explicit RecordSet(
const Statement & rStatement
);

Creates the RecordSet.

## Destructor

### ~RecordSet

~RecordSet();

Destroys the RecordSet.

## Member Functions

### column

template < class T > const Column < T > & column(
const std::string & name
) const;

Returns the reference to the first Column with the specified name.

### column

template < class T > const Column < T > & column(
std::size_t pos
) const;

Returns the reference to column at specified location.

### columnCount

std::size_t columnCount() const;

Returns the number of rows in the recordset.

### columnLength

std::size_t columnLength(
std::size_t pos
) const;

Returns column maximum length for the column at specified position.

### columnLength

std::size_t columnLength(
const std::string & name
) const;

Returns column maximum length for the column with specified name.

### columnName

const std::string & columnName(
std::size_t pos
) const;

Returns column name for the column at specified position.

### columnPrecision

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).

### columnPrecision

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).

### columnType

MetaColumn::ColumnDataType columnType(
std::size_t pos
) const;

Returns the type for the column at specified position.

### columnType

MetaColumn::ColumnDataType columnType(
const std::string & name
) const;

Returns the type for the column with specified name.

### moveFirst

bool moveFirst();

Moves the row cursor to the first row.

Returns true if there is at least one row in the RecordSet, false otherwise.

### moveLast

bool moveLast();

Moves the row cursor to the last row.

Returns true if there is at least one row in the RecordSet, false otherwise.

### moveNext

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.

### movePrevious

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.

### operator

DynamicAny operator[] (
const std::string & name
);

Returns the value in the named column of the current row.

### operator

DynamicAny operator[] (
std::size_t index
);

Returns the value in the named column of the current row.

### operator =

Statement & operator = (
const Statement & stmt
);

Assignment operator.

### rowCount

std::size_t rowCount() const;

Returns the number of rows in the recordset.

### value

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.

### value

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.

### value

DynamicAny value(
std::size_t col,
std::size_t row
) const;

Returns the reference to data value at column, row location.

### value

DynamicAny value(
const std::string & name,
std::size_t row
) const;

Returns the reference to data value at named column, row location.

### value

DynamicAny value(
const std::string & name
);

Returns the value in the named column of the current row.

### value

DynamicAny value(
std::size_t index
);

Returns the value in the given column of the current row.