Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::db::impl::PostgresPreparedStatementImpl Class Reference

PSQL prepared statement implementation. More...

#include <PostgresPreparedStatementImpl.h>

Inheritance diagram for sese::db::impl::PostgresPreparedStatementImpl:
sese::db::PreparedStatement

Public Member Functions

 PostgresPreparedStatementImpl (std::string stmt_name, std::string stmt_string, uint32_t count, PGconn *conn) noexcept
 
 ~PostgresPreparedStatementImpl () noexcept override
 
ResultSet::Ptr executeQuery () noexcept override
 Execute query.
 
int64_t executeUpdate () noexcept override
 Execute update.
 
bool setDouble (uint32_t index, const double &value) noexcept override
 Set double-precision floating-point value.
 
bool setFloat (uint32_t index, const float &value) noexcept override
 Set single-precision floating-point value.
 
bool setInteger (uint32_t index, const int32_t &value) noexcept override
 Set integer value.
 
bool setLong (uint32_t index, const int64_t &value) noexcept override
 Set long integer value.
 
bool setText (uint32_t index, const char *value) noexcept override
 Set text value.
 
bool setNull (uint32_t index) noexcept override
 Set to NULL.
 
bool setDateTime (uint32_t index, const sese::DateTime &value) noexcept override
 Set to dateTime.
 
bool getColumnType (uint32_t index, MetadataType &type) noexcept override
 Get result set column type.
 
int64_t getColumnSize (uint32_t index) noexcept override
 Get result set column size. This interface is usually only effective when the type is binary or string, and the unit is bytes.
 
int getLastError () const noexcept override
 Get the error code for the corresponding driver of the instance.
 
const char * getLastErrorMessage () const noexcept override
 Get the error message for the corresponding driver of the instance. Need to check for null.
 
- Public Member Functions inherited from sese::db::PreparedStatement
virtual ~PreparedStatement () noexcept=default
 
ErrorCode getErrorCode () const
 

Protected Attributes

PGconn * conn
 
std::string stmtName
 
std::string stmtString
 
uint32_t count
 
Oid * paramTypes
 
const char ** paramValues
 
std::string * strings
 
int error = 0
 
PGresult * result
 

Additional Inherited Members

- Public Types inherited from sese::db::PreparedStatement
using Ptr = std::unique_ptr<PreparedStatement>
 

Detailed Description

PSQL prepared statement implementation.

Constructor & Destructor Documentation

◆ PostgresPreparedStatementImpl()

sese::db::impl::PostgresPreparedStatementImpl::PostgresPreparedStatementImpl ( std::string stmt_name,
std::string stmt_string,
uint32_t count,
PGconn * conn )
explicitnoexcept

References count().

◆ ~PostgresPreparedStatementImpl()

sese::db::impl::PostgresPreparedStatementImpl::~PostgresPreparedStatementImpl ( )
overridenoexcept

Member Function Documentation

◆ executeQuery()

sese::db::ResultSet::Ptr sese::db::impl::PostgresPreparedStatementImpl::executeQuery ( )
overridevirtualnoexcept

Execute query.

Returns
Query result set
Return values
nullptrQuery failed

Implements sese::db::PreparedStatement.

References count().

◆ executeUpdate()

int64_t sese::db::impl::PostgresPreparedStatementImpl::executeUpdate ( )
overridevirtualnoexcept

Execute update.

Returns
Number of rows affected
Return values
-1Update failed

Implements sese::db::PreparedStatement.

References count().

◆ getColumnSize()

int64_t sese::db::impl::PostgresPreparedStatementImpl::getColumnSize ( uint32_t index)
nodiscardoverridevirtualnoexcept

Get result set column size. This interface is usually only effective when the type is binary or string, and the unit is bytes.

Parameters
indexIndex value
Returns
Returns -1 if failed

Implements sese::db::PreparedStatement.

◆ getColumnType()

bool sese::db::impl::PostgresPreparedStatementImpl::getColumnType ( uint32_t index,
MetadataType & type )
nodiscardoverridevirtualnoexcept

◆ getLastError()

int sese::db::impl::PostgresPreparedStatementImpl::getLastError ( ) const
nodiscardoverridevirtualnoexcept

Get the error code for the corresponding driver of the instance.

Returns
Error code

Implements sese::db::PreparedStatement.

◆ getLastErrorMessage()

const char * sese::db::impl::PostgresPreparedStatementImpl::getLastErrorMessage ( ) const
nodiscardoverridevirtualnoexcept

Get the error message for the corresponding driver of the instance. Need to check for null.

Return values
nullptrFailed to get error message
Returns
Error message

Implements sese::db::PreparedStatement.

◆ setDateTime()

bool sese::db::impl::PostgresPreparedStatementImpl::setDateTime ( uint32_t index,
const sese::DateTime & value )
nodiscardoverridevirtualnoexcept

Set to dateTime.

Parameters
indexIndex
valueDate
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), sese::text::DateTimeFormatter::format(), and TIMESTAMPOID.

◆ setDouble()

bool sese::db::impl::PostgresPreparedStatementImpl::setDouble ( uint32_t index,
const double & value )
nodiscardoverridevirtualnoexcept

Set double-precision floating-point value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and FLOAT8OID.

◆ setFloat()

bool sese::db::impl::PostgresPreparedStatementImpl::setFloat ( uint32_t index,
const float & value )
nodiscardoverridevirtualnoexcept

Set single-precision floating-point value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and FLOAT4OID.

◆ setInteger()

bool sese::db::impl::PostgresPreparedStatementImpl::setInteger ( uint32_t index,
const int32_t & value )
nodiscardoverridevirtualnoexcept

Set integer value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and INT4OID.

◆ setLong()

bool sese::db::impl::PostgresPreparedStatementImpl::setLong ( uint32_t index,
const int64_t & value )
nodiscardoverridevirtualnoexcept

Set long integer value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and INT8OID.

◆ setNull()

bool sese::db::impl::PostgresPreparedStatementImpl::setNull ( uint32_t index)
nodiscardoverridevirtualnoexcept

Set to NULL.

Parameters
indexIndex
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count().

◆ setText()

bool sese::db::impl::PostgresPreparedStatementImpl::setText ( uint32_t index,
const char * value )
nodiscardoverridevirtualnoexcept

Set text value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and TEXTOID.

Member Data Documentation

◆ conn

PGconn* sese::db::impl::PostgresPreparedStatementImpl::conn
protected

◆ count

uint32_t sese::db::impl::PostgresPreparedStatementImpl::count
protected

◆ error

int sese::db::impl::PostgresPreparedStatementImpl::error = 0
protected

◆ paramTypes

Oid* sese::db::impl::PostgresPreparedStatementImpl::paramTypes
protected

◆ paramValues

const char** sese::db::impl::PostgresPreparedStatementImpl::paramValues
protected

◆ result

PGresult* sese::db::impl::PostgresPreparedStatementImpl::result
protected

◆ stmtName

std::string sese::db::impl::PostgresPreparedStatementImpl::stmtName
protected

◆ stmtString

std::string sese::db::impl::PostgresPreparedStatementImpl::stmtString
protected

◆ strings

std::string* sese::db::impl::PostgresPreparedStatementImpl::strings
protected

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