relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
Loading...
Searching...
No Matches
relx::connection::PostgreSQLStatement Class Reference

Represents a prepared statement in PostgreSQL. More...

#include <relx/connection/postgresql_statement.hpp>

Public Member Functions

 PostgreSQLStatement (PostgreSQLConnection &connection, std::string name, std::string sql, int param_count)
 Constructor.
 
 ~PostgreSQLStatement ()
 Destructor that deallocates the prepared statement.
 
 PostgreSQLStatement (const PostgreSQLStatement &)=delete
 
PostgreSQLStatementoperator= (const PostgreSQLStatement &)=delete
 
 PostgreSQLStatement (PostgreSQLStatement &&) noexcept
 
PostgreSQLStatementoperator= (PostgreSQLStatement &&) noexcept
 
ConnectionResult< result::ResultSetexecute (const std::vector< std::string > &params={})
 Execute the prepared statement with parameters.
 
template<typename... Args>
ConnectionResult< result::ResultSetexecute_typed (Args &&... args)
 Execute the prepared statement with typed parameters.
 
const std::string & name () const
 Get the name of the prepared statement.
 
const std::string & sql () const
 Get the SQL query text.
 
int param_count () const
 Get the number of parameters.
 
bool is_valid () const
 Check if the statement is still valid.
 

Detailed Description

Represents a prepared statement in PostgreSQL.

Definition at line 20 of file postgresql_statement.hpp.

Constructor & Destructor Documentation

◆ PostgreSQLStatement() [1/3]

relx::connection::PostgreSQLStatement::PostgreSQLStatement ( PostgreSQLConnection connection,
std::string  name,
std::string  sql,
int  param_count 
)

Constructor.

Parameters
connectionThe connection that owns this prepared statement
nameThe name of the prepared statement
sqlThe SQL query text
param_countThe number of parameters in the statement

◆ ~PostgreSQLStatement()

relx::connection::PostgreSQLStatement::~PostgreSQLStatement ( )

Destructor that deallocates the prepared statement.

◆ PostgreSQLStatement() [2/3]

relx::connection::PostgreSQLStatement::PostgreSQLStatement ( const PostgreSQLStatement )
delete

◆ PostgreSQLStatement() [3/3]

relx::connection::PostgreSQLStatement::PostgreSQLStatement ( PostgreSQLStatement &&  )
noexcept

Member Function Documentation

◆ execute()

ConnectionResult< result::ResultSet > relx::connection::PostgreSQLStatement::execute ( const std::vector< std::string > &  params = {})

Execute the prepared statement with parameters.

Parameters
paramsVector of parameter values
Returns
Result containing the query results or an error

◆ execute_typed()

template<typename... Args>
ConnectionResult< result::ResultSet > relx::connection::PostgreSQLStatement::execute_typed ( Args &&...  args)
inline

Execute the prepared statement with typed parameters.

Template Parameters
ArgsThe types of the parameters
Parameters
argsThe parameter values
Returns
Result containing the query results or an error

Definition at line 51 of file postgresql_statement.hpp.

◆ is_valid()

bool relx::connection::PostgreSQLStatement::is_valid ( ) const
inline

Check if the statement is still valid.

Returns
True if the statement is valid, false otherwise

Definition at line 103 of file postgresql_statement.hpp.

◆ name()

const std::string & relx::connection::PostgreSQLStatement::name ( ) const
inline

Get the name of the prepared statement.

Returns
The name of the prepared statement

Definition at line 91 of file postgresql_statement.hpp.

◆ operator=() [1/2]

PostgreSQLStatement & relx::connection::PostgreSQLStatement::operator= ( const PostgreSQLStatement )
delete

◆ operator=() [2/2]

PostgreSQLStatement & relx::connection::PostgreSQLStatement::operator= ( PostgreSQLStatement &&  )
noexcept

◆ param_count()

int relx::connection::PostgreSQLStatement::param_count ( ) const
inline

Get the number of parameters.

Returns
The number of parameters

Definition at line 99 of file postgresql_statement.hpp.

◆ sql()

const std::string & relx::connection::PostgreSQLStatement::sql ( ) const
inline

Get the SQL query text.

Returns
The SQL query text

Definition at line 95 of file postgresql_statement.hpp.


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