Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::db::PreparedStatement Class Referenceabstract

Prepared statement object. More...

#include <PreparedStatement.h>

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

Public Types

using Ptr = std::unique_ptr<PreparedStatement>
 

Public Member Functions

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

Detailed Description

Prepared statement object.

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ ~PreparedStatement()

virtual sese::db::PreparedStatement::~PreparedStatement ( )
virtualdefaultnoexcept

Member Function Documentation

◆ executeQuery()

virtual ResultSet::Ptr sese::db::PreparedStatement::executeQuery ( )
pure virtualnoexcept

Execute query.

Returns
Query result set
Return values
nullptrQuery failed

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ executeUpdate()

virtual int64_t sese::db::PreparedStatement::executeUpdate ( )
pure virtualnoexcept

Execute update.

Returns
Number of rows affected
Return values
-1Update failed

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ getColumnSize()

virtual int64_t sese::db::PreparedStatement::getColumnSize ( uint32_t index)
pure virtualnoexcept

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

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ getColumnType()

virtual bool sese::db::PreparedStatement::getColumnType ( uint32_t index,
MetadataType & type )
pure virtualnoexcept

Get result set column type.

Parameters
indexIndex value
typeColumn type
Returns
Whether the retrieval was successful

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ getErrorCode()

ErrorCode sese::db::PreparedStatement::getErrorCode ( ) const
inline

◆ getLastError()

virtual int sese::db::PreparedStatement::getLastError ( ) const
nodiscardpure virtualnoexcept

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

Returns
Error code

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

Referenced by getErrorCode().

◆ getLastErrorMessage()

virtual const char * sese::db::PreparedStatement::getLastErrorMessage ( ) const
nodiscardpure virtualnoexcept

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

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

Referenced by getErrorCode().

◆ setDateTime()

virtual bool sese::db::PreparedStatement::setDateTime ( uint32_t index,
const sese::DateTime & value )
pure virtualnoexcept

Set to dateTime.

Parameters
indexIndex
valueDate
Returns
Whether the setting was successful

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ setDouble()

virtual bool sese::db::PreparedStatement::setDouble ( uint32_t index,
const double & value )
pure virtualnoexcept

Set double-precision floating-point value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ setFloat()

virtual bool sese::db::PreparedStatement::setFloat ( uint32_t index,
const float & value )
pure virtualnoexcept

Set single-precision floating-point value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ setInteger()

virtual bool sese::db::PreparedStatement::setInteger ( uint32_t index,
const int32_t & value )
pure virtualnoexcept

Set integer value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ setLong()

virtual bool sese::db::PreparedStatement::setLong ( uint32_t index,
const int64_t & value )
pure virtualnoexcept

Set long integer value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ setNull()

virtual bool sese::db::PreparedStatement::setNull ( uint32_t index)
pure virtualnoexcept

Set to NULL.

Parameters
indexIndex
Returns
Whether the setting was successful

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.

◆ setText()

virtual bool sese::db::PreparedStatement::setText ( uint32_t index,
const char * value )
pure virtualnoexcept

Set text value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implemented in sese::db::impl::MariaPreparedStatementImpl, sese::db::impl::PostgresPreparedStatementImpl, and sese::db::impl::SqlitePreparedStatementImpl.


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