# pqxx::basic_cursor< ACCESS, UPDATE > Class Template Reference

The simplest form of cursor, with no concept of position or stride. More...

`#include <cursor.hxx>`

Inheritance diagram for pqxx::basic_cursor< ACCESS, UPDATE >:

[legend]
List of all members.

## Public Member Functions

| basic_cursor (transaction_base *t, const PGSTD::string &query, const PGSTD::string &cname, ownershippolicy op=owned)
| Create cursor based on given query.
| basic_cursor (transaction_base *t, const PGSTD::string &cname, ownershippolicy op=owned)
| Adopt existing SQL cursor.
virtual result | fetch (difference_type n)
| Fetch a number of rows from cursor.
virtual result | fetch (difference_type n, difference_type &d)
virtual difference_type | move (difference_type n)
| Move cursor by given number of rows.
virtual difference_type | move (difference_type n, difference_type &d)

## Detailed Description

### template<cursor_base::accesspolicy ACCESS, cursor_base::updatepolicy UPDATE>
class pqxx::basic_cursor< ACCESS, UPDATE >

The simplest form of cursor, with no concept of position or stride.

## Constructor & Destructor Documentation

template<cursor_base::accesspolicy ACCESS, cursor_base::updatepolicy UPDATE>

pqxx::basic_cursor< ACCESS, UPDATE >::basic_cursor | ( | transaction_base * | t,
|  | const PGSTD::string & | query,
|  | const PGSTD::string & | cname,
|  | ownershippolicy | op = `owned` |
| ) |  |  |

Create cursor based on given query.

Parameters:

  | t | transaction this cursor is to live in
  | query | SQL query whose results this cursor will iterate
  | cname | name for this cursor, which will be changed to make it unique
  | op | are we responsible for closing this cursor?

Warning:
  If the transaction being used is a nontransaction, or if the ownership policy is "loose," a "WITH HOLD" cursor will be created. Not all backends versions support this.

template<cursor_base::accesspolicy ACCESS, cursor_base::updatepolicy UPDATE>

pqxx::basic_cursor< ACCESS, UPDATE >::basic_cursor | ( | transaction_base * | t,
|  | const PGSTD::string & | cname,
|  | ownershippolicy | op = `owned` |
| ) |  |  |

Adopt existing SQL cursor.

Create a cursor object based on an existing SQL cursor. The name must be the exact name of that cursor (and unlike the name of a newly created cursor, will not be embellished for uniqueness).

Parameters:

  | t | transaction this cursor is to live in
  | cname | exact name of this cursor, as declared in SQL
  | op | are we responsible for closing this cursor?

## Member Function Documentation

template<cursor_base::accesspolicy ACCESS, cursor_base::updatepolicy UPDATE>

virtual result pqxx::basic_cursor< ACCESS, UPDATE >::fetch | ( | difference_type | n | ) | `[virtual]`

Fetch a number of rows from cursor.

This function can be used to fetch a given number of rows (by passing the desired number of rows as an argument), or all remaining rows (by passing cursor_base::all()), or fetch a given number of rows backwards from the current position (by passing the negative of the desired number), or all rows remaining behind the current position (by using cursor_base::backwards_all()).

This function behaves slightly differently from the SQL FETCH command. Most notably, fetching zero rows does not move the cursor, and returns an empty result.

Warning:
  When zero rows are fetched, the returned result may not contain any metadata such as the number of columns and their names.

Parameters:

  | n | number of rows to fetch

Returns:
  a result set containing at most n rows of data

template<cursor_base::accesspolicy ACCESS, cursor_base::updatepolicy UPDATE>

virtual result pqxx::basic_cursor< ACCESS, UPDATE >::fetch | ( | difference_type | n,
|  | difference_type & | d |
| ) |  |  | `[virtual]`

template<cursor_base::accesspolicy ACCESS, cursor_base::updatepolicy UPDATE>

virtual difference_type pqxx::basic_cursor< ACCESS, UPDATE >::move | ( | difference_type | n | ) | `[virtual]`

Move cursor by given number of rows.

Parameters:

  | n | number of rows to move

Returns:
  number of rows actually moved (which cannot exceed n)

template<cursor_base::accesspolicy ACCESS, cursor_base::updatepolicy UPDATE>

virtual difference_type pqxx::basic_cursor< ACCESS, UPDATE >::move | ( | difference_type | n,
|  | difference_type & | d |
| ) |  |  | `[virtual]`

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

- cursor.hxx