# Poco::Data::ODBC

# class Preparation

Library: Data/ODBC
Package: ODBC
Header: Poco/Data/ODBC/Preparation.h

## Description

Class used for database preparation where we first have to register all data types with respective memory output locations before extracting data. Extraction works in two-phases: first prepare is called once, then extract n-times. In ODBC, SQLBindCol/SQLFetch is the preferred method of data retrieval (SQLGetData is available, however with numerous driver implementation dependent limitations). In order to fit this functionality into Poco DataConnectors framework, every ODBC SQL statement instantiates its own Preparation object. This is done once per statement execution (from StatementImpl::bindImpl()).

Preparation object is used to :

1) Prepare SQL statement. 2) Provide and contain the memory locations where retrieved values are placed during recordset iteration. 3) Keep count of returned number of columns with their respective datatypes and sizes.

Notes:

- Value datatypes in this interface prepare() calls serve only for the purpose of type distinction. - Preparation keeps its own std::vector<Any> buffer for fetched data to be later retrieved by Extractor. - prepare() methods should not be called when extraction mode is DE_MANUAL

## Inheritance

Direct Base Classes: Poco::Data::AbstractPreparation

All Base Classes: Poco::Data::AbstractPreparation, Poco::RefCountedObject

## Member Summary

Member Functions: actualDataSize, columns, getDataExtraction, getMaxFieldSize, maxDataSize, operator, prepare, setDataExtraction, setMaxFieldSize

Inherited Functions: duplicate, prepare, referenceCount, release

## Enumerations

### DataExtraction

DE_MANUAL

DE_BOUND

## Constructors

### Preparation

Preparation(
const StatementHandle & rStmt,
const std::string & statement,
std::size_t maxFieldSize,
DataExtraction dataExtraction = DE_BOUND
);

Creates the Preparation.

## Destructor

### ~Preparation

~Preparation();

Destroys the Preparation.

## Member Functions

### actualDataSize

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

Returns the returned length. This is usually equal to the column size, except for variable length fields (BLOB and variable length strings).

### columns

std::size_t columns() const;

Returns the number of columns.

### getDataExtraction

DataExtraction getDataExtraction() const;

Returns data extraction mode.

### getMaxFieldSize

std::size_t getMaxFieldSize() const;

### maxDataSize

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

Returns max supported size for column at position pos. Returned length for variable length fields is the one supported by this implementation, not the underlying DB.

### operator

Poco::Any & operator[] (
std::size_t pos
);

Returns reference to column data.

### prepare

void prepare(
std::size_t pos,
Poco::Int8
);

Prepares an Int8.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
Poco::UInt8
);

Prepares an UInt8.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
Poco::Int16
);

Prepares an Int16.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
Poco::UInt16
);

Prepares an UInt16.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
Poco::Int32
);

Prepares an Int32.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
Poco::UInt32
);

Prepares an UInt32.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
Poco::Int64
);

Prepares an Int64.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
Poco::UInt64
);

Prepares an UInt64.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
bool
);

Prepares a boolean.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
float
);

Prepares a float.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
double
);

Prepares a double.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
char
);

Prepares a single character.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
const std::string & param22
);

Prepares a string.

See also: Poco::Data::AbstractPreparation::prepare()

### prepare

void prepare(
std::size_t pos,
const Poco::Data::BLOB & param23
);

Prepares a BLOB.

### prepare

void prepare(
std::size_t pos,
const Poco::Any & param24
);

Prepares an Any.

### setDataExtraction

void setDataExtraction(
DataExtraction ext
);

Set data extraction mode.

### setMaxFieldSize

void setMaxFieldSize(
std::size_t size
);

Sets maximum supported field size.