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

# Poco::Data

# class Statement

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

## Description

A Statement is used to execute SQL statements. It does not contain code of its own. Its main purpose is to forward calls to the concrete StatementImpl stored inside.

## Inheritance

Known Derived Classes: RecordSet

## Member Summary

Member Functions: done, execute, extractions, metaColumn, operator <<, operator =, operator,, swap, toString

## Types

### void

typedef void (* Manipulator)(Statement &);

## Constructors

### Statement

Statement(
StatementImpl * pImpl
);

Creates the Statement.

### Statement

explicit Statement(
Session & session
);

Creates the Statement for the given Session.

The following:

    Statement stmt(sess);
    stmt << "SELECT * FROM Table", ...

is equivalent to:

    Statement stmt(sess << "SELECT * FROM Table", ...);

but in some cases better readable.

### Statement

Statement(
const Statement & stmt
);

Copy constructor

## Destructor

### ~Statement

~Statement();

Destroys the Statement.

## Member Functions

### done

bool done();

Returns if the statement was completely executed or if a previously set limit stopped it and there is more work to do. When no limit is set, it will always - after calling execute() - return true.

### execute

Poco::UInt32 execute();

Executes the whole statement. Stops when either a limit is hit or the whole statement was executed. Returns the number of rows extracted from the Database.

### operator <<

template < typename T > Statement & operator << (
const T & t
);

Concatenates the send data to a string version of the SQL statement.

### operator =

Statement & operator = (
const Statement & stmt
);

Assignment operator.

### operator,

Statement & operator, (
Manipulator manip
);

Handles manipulators, such as now.

### operator,

Statement & operator, (
AbstractBinding * info
);

Registers the Binding at the Statement

### operator,

Statement & operator, (
AbstractExtraction * extract
);

Registers objects used for extracting data at the Statement.

### operator,

Statement & operator, (
const Limit & extrLimit
);

Sets a limit on the maximum number of rows a select is allowed to return.

Set per default to Limit::LIMIT_UNLIMITED which disables the limit.

### operator,

Statement & operator, (
const Range & extrRange
);

Sets a an etxraction Range on the maximum number of rows a select is allowed to return.

Set per default to Limit::LIMIT_UNLIMITED which disables the range.

### swap

void swap(
Statement & other
);

Swaps the statement with another one.

### toString

std::string toString() const;

Creates a string from the accumulated SQL statement

### extractions

const AbstractExtractionVec & extractions() const;

Returns the extractions vector.

### metaColumn

const MetaColumn & metaColumn(
std::size_t pos
) const;

Returns the type for the column at specified position.

### metaColumn

const MetaColumn & metaColumn(
const std::string & name
) const;

Returns the type for the column with specified name.