# pqxx::result Class Reference

Query or command result set. More...

`#include <result.hxx>`

Inheritance diagram for pqxx::result:

[legend]

List of all members.

## Classes
class | const_fielditerator
class | const_iterator
| Iterator for rows (tuples) in a query result set. More...
class | const_reverse_fielditerator
class | const_reverse_iterator
class | field
| Reference to a field in a result set. More...
class | tuple
| Reference to one row in a result. More...
## Public Types
typedef unsigned long | size_type
typedef signed long | difference_type
typedef tuple | reference
typedef const_iterator | pointer
typedef std::iterator < std::random_access_iterator_tag, const tuple, result::difference_type, const_iterator, tuple > | const_iterator_base
## Public Member Functions
| result () throw ()
| result (const result &rhs) throw ()
result & | operator= (const result &rhs) throw ()
const_reverse_iterator | rbegin () const
const_reverse_iterator | rend () const
const_iterator | begin () const throw ()
const_iterator | end () const throw ()
reference | front () const throw ()
reference | back () const throw ()
size_type | size () const throw ()
bool | empty () const throw ()
size_type | capacity () const throw ()
void | swap (result &) throw ()
const tuple | operator[] (size_type i) const throw ()
const tuple | at (size_type) const throw (range_error)
void | clear () throw ()
const std::string & | query () const throw ()
| Query that produced this result, if available (empty string otherwise).
oid | inserted_oid () const
| If command was `INSERT` of 1 row, return oid of inserted row.
size_type | affected_rows () const
| If command was `INSERT`, `UPDATE`, or `DELETE:` number of affected rows.
Comparisons
bool | operator== (const result &) const throw ()
bool | operator!= (const result &rhs) const throw ()
Column information
tuple::size_type | columns () const throw ()
| Number of columns in result.
tuple::size_type | column_number (const char ColName[]) const
| Number of given column (throws exception if it doesn't exist).
tuple::size_type | column_number (const std::string &Name) const
| Number of given column (throws exception if it doesn't exist).
const char * | column_name (tuple::size_type Number) const
| Name of column with this number (throws exception if it doesn't exist).
oid | column_type (tuple::size_type ColNum) const
| Type of given column.
oid | column_type (int ColNum) const
| Type of given column.
oid | column_type (const std::string &ColName) const
| Type of given column.
oid | column_type (const char ColName[]) const
| Type of given column.
oid | column_table (tuple::size_type ColNum) const
| What table did this column come from? Requires PostgreSQL 7.4 C API.
oid | column_table (int ColNum) const
| What table did this column come from? Requires PostgreSQL 7.4 C API.
oid | column_table (const std::string &ColName) const
| What table did this column come from? Requires PostgreSQL 7.4 C API.
tuple::size_type | table_column (tuple::size_type ColNum) const
| What column in its table did this column come from?
tuple::size_type | table_column (int ColNum) const
| What column in its table did this column come from?
tuple::size_type | table_column (const std::string &ColName) const
| What column in its table did this column come from?
## Package Attributes
| __pad0__:PQAlloc<internal::result_data> super
## Friends
class | pqxx::result::field
class | connection_base
class | pipeline
class | Cursor
class | internal::sql_cursor

## Detailed Description

Query or command result set.

This behaves as a container (as defined by the C++ standard library) and provides random access const iterators to iterate over its tuples. A tuple can also be accessed by indexing a result R by the tuple's zero-based number:

            for (result::size_type i=0; i < R.size(); ++i) Process(R[i]);

Result sets in libpqxx are lightweight, reference-counted wrapper objects (following the Proxy design pattern) that are small and cheap to copy. Think of a result object as a "smart pointer" to an underlying result set.

Warning:
  The result set that a result object points to is not thread-safe. If you copy a result object, it still refers to the same underlying result set. So never copy, destroy, query, or otherwise access a result while another thread may be copying, destroying, querying, or otherwise accessing the same result set--even if it is doing so through a different result object!

## Member Typedef Documentation

typedef std ::iterator< std ::random_access_iterator_tag, const tuple, result::difference_type, const_iterator, tuple> pqxx::result::const_iterator_base

typedef signed long pqxx::result::difference_type

typedef const_iterator pqxx::result::pointer

typedef tuple pqxx::result::reference

typedef unsigned long pqxx::result::size_type

## Constructor & Destructor Documentation

pqxx::result::result | ( |  | ) | throw ()

pqxx::result::result | ( | const result & | rhs | ) | throw ()

## Member Function Documentation

pqxx::result::size_type pqxx::result::affected_rows | ( |  | ) | const

If command was `INSERT`, `UPDATE`, or `DELETE:` number of affected rows.

Returns:
  Number of affected rows if last command was `INSERT`, `UPDATE`, or `DELETE`; zero for all other commands.

Referenced by pqxx::internal::sql_cursor::move().

const pqxx::result::tuple pqxx::result::at | ( | size_type | i | ) | const throw (range_error)

reference pqxx::result::back | ( |  | ) | const throw ()

const_iterator pqxx::result::begin | ( |  | ) | const throw ()

size_type pqxx::result::capacity | ( |  | ) | const throw ()

void pqxx::result::clear | ( |  | ) | throw ()

Reimplemented from pqxx::internal::PQAlloc< internal::result_data >.

Referenced by pqxx::icursor_iterator::operator++(), and pqxx::icursor_iterator::operator+=().

const char * pqxx::result::column_name | ( | tuple::size_type | Number | ) | const

Name of column with this number (throws exception if it doesn't exist).

References pqxx::to_string().

tuple::size_type pqxx::result::column_number | ( | const std::string & | Name | ) | const

Number of given column (throws exception if it doesn't exist).

References column_number().

Referenced by column_number().

pqxx::result::tuple::size_type pqxx::result::column_number | ( | const char | ColName[] | ) | const

Number of given column (throws exception if it doesn't exist).

Referenced by pqxx::result::result::tuple::at(), and pqxx::result::result::tuple::operator[]().

oid pqxx::result::column_table | ( | const std::string & | ColName | ) | const

What table did this column come from? Requires PostgreSQL 7.4 C API.

Only defined if the libpqxx library was compiled against a libpq version that supports the `PQftable` function.

If you get a link error saying this function is undefined, that must be because libpqxx was compiled against an older version of libpq. The `PQftable` function first became available in PostgreSQL 7.4.

References column_table().

Referenced by column_table().

oid pqxx::result::column_table | ( | int | ColNum | ) | const

What table did this column come from? Requires PostgreSQL 7.4 C API.

Only defined if the libpqxx library was compiled against a libpq version that supports the `PQftable` function.

If you get a link error saying this function is undefined, that must be because libpqxx was compiled against an older version of libpq. The `PQftable` function first became available in PostgreSQL 7.4.

References column_table().

Referenced by column_table().

oid pqxx::result::column_table | ( | tuple::size_type | ColNum | ) | const

What table did this column come from? Requires PostgreSQL 7.4 C API.

Only defined if the libpqxx library was compiled against a libpq version that supports the `PQftable` function.

If you get a link error saying this function is undefined, that must be because libpqxx was compiled against an older version of libpq. The `PQftable` function first became available in PostgreSQL 7.4.

oid pqxx::result::column_type | ( | const char | ColName[] | ) | const

Type of given column.

References column_type().

Referenced by column_type().

oid pqxx::result::column_type | ( | const std::string & | ColName | ) | const

Type of given column.

References column_type().

Referenced by column_type().

oid pqxx::result::column_type | ( | int | ColNum | ) | const

Type of given column.

References column_type().

Referenced by column_type().

pqxx::oid pqxx::result::column_type | ( | tuple::size_type | ColNum | ) | const

Type of given column.

References pqxx::oid_none, and pqxx::to_string().

pqxx::result::tuple::size_type pqxx::result::columns | ( |  | ) | const throw ()

Number of columns in result.

bool pqxx::result::empty | ( |  | ) | const throw ()

Referenced by pqxx::icursor_iterator::operator<(), and pqxx::icursor_iterator::operator==().

result::const_iterator pqxx::result::end | ( |  | ) | const throw ()

References size().

reference pqxx::result::front | ( |  | ) | const throw ()

pqxx::oid pqxx::result::inserted_oid | ( |  | ) | const

If command was `INSERT` of 1 row, return oid of inserted row.

Returns:
  Identifier of inserted row if exactly one row was inserted, or oid_none otherwise.

bool pqxx::result::operator!= | ( | const result & | rhs | ) | const throw ()

result& pqxx::result::operator= | ( | const result & | rhs | ) | throw ()

bool pqxx::result::operator== | ( | const result & | rhs | ) | const throw ()

const tuple pqxx::result::operator[] | ( | size_type | i | ) | const throw ()

Referenced by pqxx::result::result::tuple::at().

const string & pqxx::result::query | ( |  | ) | const throw ()

Query that produced this result, if available (empty string otherwise).

References pqxx::internal::PQAlloc< internal::result_data >::c_ptr(), and pqxx::internal::result_data::query.

const_reverse_iterator pqxx::result::rbegin | ( |  | ) | const

const_reverse_iterator pqxx::result::rend | ( |  | ) | const

pqxx::result::size_type pqxx::result::size | ( |  | ) | const throw ()

Referenced by pqxx::result::result::tuple::at(), end(), and pqxx::internal::sql_cursor::fetch().

void pqxx::result::swap | ( | result & | rhs | ) | throw ()

tuple::size_type pqxx::result::table_column | ( | const std::string & | ColName | ) | const

What column in its table did this column come from?

References table_column().

Referenced by table_column().

tuple::size_type pqxx::result::table_column | ( | int | ColNum | ) | const

What column in its table did this column come from?

References table_column().

Referenced by table_column().

tuple::size_type pqxx::result::table_column | ( | tuple::size_type | ColNum | ) | const

What column in its table did this column come from?

## Friends And Related Function Documentation

friend class connection_base`[friend]`

friend class Cursor`[friend]`

friend class internal::sql_cursor`[friend]`

friend class pipeline`[friend]`

friend class pqxx::result::field`[friend]`

## Member Data Documentation

pqxx::result::__pad0__`[package]`

The documentation for this class was generated from the following files:

- result.hxx
- result.cxx