lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lintel::postgresql::Cursor Class Reference

#include <Cursor.h>

Public Member Functions

 Cursor (const Connection &connection, const std::string &query, const std::vector< std::string > &params)
 
 Cursor (const Connection &connection, const std::string &query, const std::vector< std::string > &params, std::size_t fetchSize, const std::string &cursorName, bool noScroll)
 
 Cursor (Cursor &cursor)=delete
 
 ~Cursor ()
 
std::vector< db::Arguments > fetchNext (std::size_t maxRows)
 

Detailed Description

Forward-only cursor over a PostgreSQL query result.

Two modes:

The underlying Connection must outlive the cursor and must not run other queries while the cursor is active. The destructor closes (server-side) or drains (streaming) to leave the connection clean.

Constructor & Destructor Documentation

◆ Cursor() [1/3]

lintel::postgresql::Cursor::Cursor ( const Connection &  connection,
const std::string &  query,
const std::vector< std::string > &  params 
)
explicit

Streaming constructor (single-row mode, no DECLARE CURSOR).

Parameters
connectionthe PostgreSQL connection (must outlive the cursor)
querythe SQL query with $1, $2, ... placeholders
paramsthe parameter values to bind
Exceptions
db::SQLExceptionif sending the query or switching to single-row mode fails

◆ Cursor() [2/3]

lintel::postgresql::Cursor::Cursor ( const Connection &  connection,
const std::string &  query,
const std::vector< std::string > &  params,
std::size_t  fetchSize,
const std::string &  cursorName,
bool  noScroll 
)
explicit

Server-side cursor constructor (DECLARE CURSOR / FETCH / CLOSE).

Parameters
connectionthe PostgreSQL connection (must outlive the cursor)
querythe SQL query with $1, $2, ... placeholders
paramsthe parameter values to bind
fetchSizenumber of rows per FETCH (must be > 0)
cursorNamethe cursor name; if empty a name is generated
noScrollif true the cursor is declared NO SCROLL
Exceptions
db::SQLExceptionif DECLARE CURSOR fails

◆ Cursor() [3/3]

lintel::postgresql::Cursor::Cursor ( Cursor &  cursor)
delete

◆ ~Cursor()

lintel::postgresql::Cursor::~Cursor ( )

Destructor, closes or drains pending results.

Member Function Documentation

◆ fetchNext()

std::vector< db::Arguments > lintel::postgresql::Cursor::fetchNext ( std::size_t  maxRows)

Fetches up to maxRows further rows from the query.

Parameters
maxRowsmaximum number of rows to fetch (must be > 0)
Returns
the fetched rows; fewer rows than requested means the result set is exhausted
Exceptions
db::SQLExceptionon server-side failure

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