pqxx::result Class Reference

Result set containing data returned by a query or command. More...

`#include <result.hxx>`

## Public Types

using | size_type = result_size_type
using | difference_type = result_difference_type
using | reference = row
using | const_iterator = const_result_iterator
using | pointer = const_iterator
using | iterator = const_iterator
using | const_reverse_iterator = const_reverse_result_iterator
using | reverse_iterator = const_reverse_iterator

## Public Member Functions

| result () noexcept
| result (const result &rhs) noexcept=default
result & | operator= (const result &rhs) noexcept=default
Comparisons
bool | operator== (const result &) const noexcept
bool | operator!= (const result &rhs) const noexcept
const_reverse_iterator | rbegin () const
const_reverse_iterator | crbegin () const
const_reverse_iterator | rend () const
const_reverse_iterator | crend () const
const_iterator | begin () const noexcept
const_iterator | cbegin () const noexcept
const_iterator | end () const noexcept
const_iterator | cend () const noexcept
reference | front () const noexcept
reference | back () const noexcept
PQXX_PURE size_type | size () const noexcept
PQXX_PURE bool | empty () const noexcept
size_type | capacity () const noexcept
void | swap (result &) noexcept
const row | operator[] (size_type i) const noexcept
const row | at (size_type) const
void | clear () noexcept

## Column information

class | pqxx::field
class | pqxx::internal::gate::result_creation
class | pqxx::internal::gate::result_connection
class | pqxx::internal::gate::result_row
class | pqxx::internal::gate::result_sql_cursor
PQXX_PURE row_size_type | columns () const noexcept
| Number of columns in result. More...
row_size_type | column_number (const char ColName[]) const
| Number of given column (throws exception if it doesn't exist). More...
row_size_type | column_number (const std::string &Name) const
| Number of given column (throws exception if it doesn't exist). More...
const char * | column_name (row_size_type Number) const
| Name of column with this number (throws exception if it doesn't exist) More...
oid | column_type (row_size_type ColNum) const
| Type of given column. More...
oid | column_type (int ColNum) const
| Type of given column. More...
oid | column_type (const std::string &ColName) const
| Type of given column. More...
oid | column_type (const char ColName[]) const
| Type of given column. More...
oid | column_table (row_size_type ColNum) const
| What table did this column come from? More...
oid | column_table (int ColNum) const
| What table did this column come from? More...
oid | column_table (const std::string &ColName) const
| What table did this column come from? More...
row_size_type | table_column (row_size_type ColNum) const
| What column in its table did this column come from? More...
row_size_type | table_column (int ColNum) const
| What column in its table did this column come from? More...
row_size_type | table_column (const std::string &ColName) const
| What column in its table did this column come from? More...
const PQXX_PURE std::string & | query () const noexcept
| Query that produced this result, if available (empty string otherwise) More...
PQXX_PURE oid | inserted_oid () const
| If command was `INSERT` of 1 row, return oid of inserted row. More...
PQXX_PURE size_type | affected_rows () const
| If command was `INSERT`, `UPDATE`, or `DELETE:` number of affected rows. More...

## Detailed Description

Result set containing data returned by a query or command.

This behaves as a container (as defined by the C++ standard library) and provides random access const iterators to iterate over its rows. A row can also be accessed by indexing a result R by the row'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 which are relatively 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

## const_iterator

using pqxx::result::const_iterator = const_result_iterator

## const_reverse_iterator

using pqxx::result::const_reverse_iterator = const_reverse_result_iterator

## difference_type

using pqxx::result::difference_type = result_difference_type

## iterator

using pqxx::result::iterator = const_iterator

## pointer

using pqxx::result::pointer = const_iterator

## reference

using pqxx::result::reference = row

## reverse_iterator

using pqxx::result::reverse_iterator = const_reverse_iterator

## size_type

using pqxx::result::size_type = result_size_type

## Constructor & Destructor Documentation

## result() [1/2]

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

noexcept

## result() [2/2]

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

default noexcept

## Member Function Documentation

## affected_rows()

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.

## at()

const pqxx::row pqxx::result::at | ( | size_type | i | ) | const

## back()

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

noexcept

## begin()

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

noexcept

## capacity()

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

noexcept

## cbegin()

pqxx::result::const_iterator pqxx::result::cbegin | ( |  | ) | const

noexcept

## cend()

const_result_iterator pqxx::result::cend | ( |  | ) | const

noexcept

References end().

## clear()

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

noexcept

Referenced by pqxx::transaction_base::reactivation_avoidance_clear().

## column_name()

const char * pqxx::result::column_name | ( | row_size_type | Number | ) | const

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

References pqxx::to_string().

## column_number() [1/2]

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

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

Referenced by pqxx::row::column_number().

## column_number() [2/2]

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

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

## column_table() [1/3]

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

What table did this column come from?

## column_table() [2/3]

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

What table did this column come from?

## column_table() [3/3]

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

What table did this column come from?

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

## column_type() [1/4]

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

Type of given column.

## column_type() [2/4]

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

Type of given column.

## column_type() [3/4]

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

Type of given column.

## column_type() [4/4]

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

Type of given column.

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

## columns()

pqxx::row::size_type pqxx::result::columns | ( |  | ) | const

noexcept

Number of columns in result.

## crbegin()

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

## crend()

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

## empty()

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

noexcept

Referenced by pqxx::icursor_iterator::operator==().

## end()

const_result_iterator pqxx::result::end | ( |  | ) | const

noexcept

References size().

Referenced by cend().

## front()

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

noexcept

## inserted_oid()

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.

## operator!=()

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

noexcept

## operator=()

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

default noexcept

## operator==()

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

noexcept

## operator[]()

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

noexcept

## query()

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

noexcept

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

## rbegin()

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

## rend()

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

## size()

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

noexcept

Referenced by end(), and pqxx::transaction_base::exec_n().

## swap()

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

noexcept

## table_column() [1/3]

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

What column in its table did this column come from?

## table_column() [2/3]

row_size_type pqxx::result::table_column | ( | int | ColNum | ) | const

What column in its table did this column come from?

## table_column() [3/3]

pqxx::row::size_type pqxx::result::table_column | ( | row_size_type | ColNum | ) | const

What column in its table did this column come from?

References pqxx::to_string().

## Friends And Related Function Documentation

## pqxx::field

friend class pqxx::field

friend

## pqxx::internal::gate::result_connection

friend class pqxx::internal::gate::result_connection

friend

## pqxx::internal::gate::result_creation

friend class pqxx::internal::gate::result_creation

friend

## pqxx::internal::gate::result_row

friend class pqxx::internal::gate::result_row

friend

## pqxx::internal::gate::result_sql_cursor

friend class pqxx::internal::gate::result_sql_cursor

friend

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

- result.hxx
- result_iterator.hxx
- result.cxx
- row.cxx

pqxx::result::size
PQXX_PURE size_type size() const noexcept
Definition: result.cxx:94
pqxx::result::size_type
result_size_type size_type
Definition: result.hxx:72