pqxx::result Class Reference

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

`#include <result.hxx>`

Inheritance diagram for pqxx::result:

## Public Types

typedef unsigned long | size_type
typedef signed long | difference_type
typedef pqxx::tuple | reference
typedef const_result_iterator | const_iterator
typedef const_iterator | pointer
typedef const_iterator | iterator
typedef const_reverse_result_iterator | const_reverse_iterator
typedef const_reverse_iterator | reverse_iterator
typedef pqxx::tuple | tuple
| For backward compatibility only. More...
typedef pqxx::field | field
| For backward compatibility only. More...

## 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 PQXX_PURE | size () const throw ()
bool PQXX_PURE | 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 &PQXX_PURE | query () const throw ()
| Query that produced this result, if available (empty string otherwise) More...
oid PQXX_PURE | inserted_oid () const
| If command was `INSERT` of 1 row, return oid of inserted row. More...
size_type PQXX_PURE | affected_rows () const
| If command was `INSERT`, `UPDATE`, or `DELETE:` number of affected rows. More...
Comparisons
bool | operator== (const result &) const throw ()
bool | operator!= (const result &rhs) const throw ()
Column information
tuple::size_type PQXX_PURE | columns () const throw ()
| Number of columns in result. More...
tuple::size_type | column_number (const char ColName[]) const
| Number of given column (throws exception if it doesn't exist) More...
tuple::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 (tuple::size_type Number) const
| Name of column with this number (throws exception if it doesn't exist) More...
oid | column_type (tuple::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 (tuple::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...
tuple::size_type | table_column (tuple::size_type ColNum) const
| What column in its table did this column come from? More...
tuple::size_type | table_column (int ColNum) const
| What column in its table did this column come from? More...
tuple::size_type | table_column (const std::string &ColName) const
| What column in its table did this column come from? More...

## Friends

class | pqxx::field
class | pqxx::internal::gate::result_creation
class | pqxx::internal::gate::result_connection
class | pqxx::internal::gate::result_sql_cursor

## 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 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

## const_iterator

typedef const_result_iterator pqxx::result::const_iterator

## const_reverse_iterator

typedef const_reverse_result_iterator pqxx::result::const_reverse_iterator

## difference_type

typedef signed long pqxx::result::difference_type

## field

typedef pqxx::field pqxx::result::field

For backward compatibility only.

Deprecated:
  Use `pqxx::field` instead.

## iterator

typedef const_iterator pqxx::result::iterator

## pointer

typedef const_iterator pqxx::result::pointer

## reference

typedef pqxx::tuple pqxx::result::reference

## reverse_iterator

typedef const_reverse_iterator pqxx::result::reverse_iterator

## size_type

typedef unsigned long pqxx::result::size_type

## tuple

typedef pqxx::tuple pqxx::result::tuple

For backward compatibility only.

Deprecated:
  Use `pqxx::tuple` instead.

## Constructor & Destructor Documentation

## result() [1/2]

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

## result() [2/2]

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

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

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

## at()

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

References pqxx::to_string().

Referenced by pqxx::connection_base::get_variable(), and pqxx::pipeline::resume().

## back()

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

## begin()

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

## capacity()

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

## clear()

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

## column_name()

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

## column_number() [1/2]

pqxx::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::tuple::column_number().

## column_number() [2/2]

tuple::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]

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

What table did this column come from?

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

## column_table() [2/3]

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

What table did this column come from?

## column_table() [3/3]

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

What table did this column come from?

## column_type() [1/4]

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

Type of given column.

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

## column_type() [2/4]

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

Type of given column.

## column_type() [3/4]

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

Type of given column.

## column_type() [4/4]

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

Type of given column.

## columns()

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

Number of columns in result.

## empty()

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

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

## end()

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

## front()

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

## 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
throw | ( |
| ) |  |

## operator=()

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

## operator==()

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

## operator[]()

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

## query()

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

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
throw | ( |
| ) |  |

Referenced by pqxx::internal::sql_cursor::fetch(), and pqxx::pipeline::resume().

## swap()

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

## table_column() [1/3]

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

What column in its table did this column come from?

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

## table_column() [2/3]

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

What column in its table did this column come from?

## table_column() [3/3]

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

What column in its table did this column come from?

## 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_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.cxx
- tuple.cxx