HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_SqlStatement Class Reference

#include <UT_SQL.h>

Public Types

using null_tag_t = UT_SqlStatementImpl::null_tag_t
 
using Blob = UT_SqlStatementImpl::Blob
 
using DataType = UT_SqlStatementImpl::DataType
 

Public Member Functions

 UT_SqlStatement (const UT_SqlDatabase &con, const UT_StringRef &sql)
 
 UT_SqlStatement (const UT_SqlDatabase &con)
 
 UT_SqlStatement (const UT_SqlBaseDriver &driver, const UT_StringRef &sql)
 
 UT_SqlStatement (const UT_SqlBaseDriver &driver)
 
 UT_SqlStatement (const UT_SharedPtr< UT_SqlStatementImpl > &impl)
 
 ~UT_SqlStatement ()
 
 UT_NON_COPYABLE (UT_SqlStatement)
 
 UT_SqlStatement (UT_SqlStatement &&stmt) noexcept
 
UT_SqlStatementoperator= (UT_SqlStatement &&)=delete
 
void reset (bool clear_bindings=false)
 
NO_DISCARD int columnAsInt (int idx) const
 
NO_DISCARD bool columnAsBool (int idx) const
 
NO_DISCARD int64 columnAsInt64 (int idx) const
 
NO_DISCARD UT_StringHolder columnAsStr (int idx) const
 
NO_DISCARD double columnAsDouble (int idx) const
 
NO_DISCARD UT_IntArray columnAsIntArray (int idx) const
 
NO_DISCARD UT_Int64Array columnAsInt64Array (int idx) const
 
NO_DISCARD UT_DateTimeField columnAsDate (int idx) const
 
NO_DISCARD const voidcolumnAsBlob (int idx, int &size) const
 
NO_DISCARD Blob columnAsBlob (int idx) const
 
NO_DISCARD null_tag_t columnAsNull (int idx) const
 
NO_DISCARD UT_StringHolder columnName (int idx) const
 
NO_DISCARD int columnCount () const
 
NO_DISCARD DataType columnType (int idx) const
 
NO_DISCARD int columnBytes (int idx) const
 
const char * sql () const
 
bool bind (int idx, null_tag_t)
 
bool bind (int idx, const UT_StringRef &value)
 
bool bind (int idx, const char *value)
 
bool bind (int idx, int value)
 
bool bind (int idx, int64 value)
 
bool bind (int idx, bool value)
 
bool bind (int idx, double value)
 
bool bind (int idx, const UT_IntArray &value)
 
bool bind (int idx, const UT_Int64Array &value)
 
bool bind (int idx, const UT_StringArray &value)
 
bool bind (int idx, const void *value, int size)
 
bool bind (int idx, Blob blob)
 
bool bind (int idx, const UT_DateTimeField &dt)
 
template<typename T , std::enable_if_t< UT::has_sql_bind_v< UT_SqlStatement, T >, bool > = true>
bool bind (int idx, const T &v)
 
const UT_StringHolderintTypeString () const
 
const UT_StringHolderbigIntTypeString () const
 
const UT_StringHolderstringTypeString () const
 
const UT_StringHoldernullTypeString () const
 
const UT_StringHolderrealTypeString () const
 
const UT_StringHolderblobTypeString () const
 
const UT_StringHolderdateTimeTypeString () const
 
const UT_StringHolderboolTypeString () const
 
template<typename T >
T get (int idx) const
 
template<typename... Args>
bool bindAll (Args &&...args)
 
bool bindNull (int idx)
 
NO_DISCARD bool isValid () const
 
bool hasRow ()
 
bool run ()
 
bool step ()
 
const UT_ErrorCodegetError () const
 
bool prepare (const UT_StringRef &sql, UT_ErrorCode &ec)
 
bool prepare (const UT_SqlStatementHandleId &id, const UT_StringRef &sql, UT_ErrorCode &ec)
 
template<typename... Args>
UT_SqlResult execute (const UT_StringRef &sql, Args &&...args)
 Helper function to create a new statement to run a new sql statement. More...
 
template<typename... Args>
UT_SqlResult execute (const UT_SqlStatementHandleId &id, const UT_StringRef &sql, Args &&...args)
 Helper function to create a new statement to run a new sql statement. More...
 
template<typename... Args>
UT_SqlResult executePrepared (Args &&...args)
 
template<typename... Args>
std::optional< std::tuple
< Args...> > 
fetchOne (UT_ErrorCode *ec=nullptr)
 
template<typename... Args>
UT_Array< std::tuple< Args...> > fetchAll (UT_ErrorCode *ec=nullptr)
 
template<typename T >
UT_Array< TfetchAllFlat (UT_ErrorCode *ec=nullptr)
 
template<typename... Args>
std::optional< std::tuple
< std::tuple< Args...> > > 
as (UT_ErrorCode *ec=nullptr)
 
NO_DISCARD bool tableExists (const UT_StringRef &name, UT_ErrorCode *ec=nullptr) const
 
int changes () const
 
bool isImplEqual (const UT_SqlStatement &rhs) const
 
template<>
double get (int idx) const
 
template<>
UT_StringHolder get (int idx) const
 
template<>
int get (int idx) const
 
template<>
int64 get (int idx) const
 
template<>
bool get (int idx) const
 
template<>
UT_DateTimeField get (int idx) const
 
template<>
const voidget (int idx) const
 

Protected Member Functions

bool bindHelper (int)
 
template<typename T , typename... Args>
bool bindHelper (int idx, T value, Args &&...args)
 
template<class... Args, std::size_t... Idxs>
std::tuple< Args...> fetchRow_ (std::index_sequence< Idxs...>)
 

Detailed Description

Definition at line 470 of file UT_SQL.h.

Member Typedef Documentation

Definition at line 474 of file UT_SQL.h.

Constructor & Destructor Documentation

UT_SqlStatement::UT_SqlStatement ( const UT_SqlDatabase con,
const UT_StringRef sql 
)
UT_SqlStatement::UT_SqlStatement ( const UT_SqlDatabase con)
UT_SqlStatement::UT_SqlStatement ( const UT_SqlBaseDriver driver,
const UT_StringRef sql 
)
UT_SqlStatement::UT_SqlStatement ( const UT_SqlBaseDriver driver)
UT_SqlStatement::UT_SqlStatement ( const UT_SharedPtr< UT_SqlStatementImpl > &  impl)
UT_SqlStatement::~UT_SqlStatement ( )
UT_SqlStatement::UT_SqlStatement ( UT_SqlStatement &&  stmt)
noexcept

Member Function Documentation

template<typename... Args>
std::optional<std::tuple<std::tuple<Args...> > > UT_SqlStatement::as ( UT_ErrorCode ec = nullptr)
inline

Definition at line 857 of file UT_SQL.h.

const UT_StringHolder& UT_SqlStatement::bigIntTypeString ( ) const
inline

Definition at line 623 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
null_tag_t   
)
inline

Definition at line 556 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
const UT_StringRef value 
)
inline

Definition at line 560 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
const char *  value 
)
inline

Definition at line 564 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
int  value 
)
inline

Definition at line 568 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
int64  value 
)
inline

Definition at line 572 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
bool  value 
)
inline

Definition at line 576 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
double  value 
)
inline

Definition at line 580 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
const UT_IntArray value 
)
inline

Definition at line 585 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
const UT_Int64Array value 
)
inline

Definition at line 589 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
const UT_StringArray value 
)
inline

Definition at line 593 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
const void value,
int  size 
)
inline

Definition at line 599 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
Blob  blob 
)
inline

Definition at line 603 of file UT_SQL.h.

bool UT_SqlStatement::bind ( int  idx,
const UT_DateTimeField dt 
)
inline

Definition at line 607 of file UT_SQL.h.

template<typename T , std::enable_if_t< UT::has_sql_bind_v< UT_SqlStatement, T >, bool > = true>
bool UT_SqlStatement::bind ( int  idx,
const T v 
)
inline

Definition at line 614 of file UT_SQL.h.

template<typename... Args>
bool UT_SqlStatement::bindAll ( Args &&...  args)
inline

Definition at line 672 of file UT_SQL.h.

bool UT_SqlStatement::bindHelper ( int  )
inlineprotected

Definition at line 891 of file UT_SQL.h.

template<typename T , typename... Args>
bool UT_SqlStatement::bindHelper ( int  idx,
T  value,
Args &&...  args 
)
inlineprotected

Definition at line 894 of file UT_SQL.h.

bool UT_SqlStatement::bindNull ( int  idx)
inline

Definition at line 675 of file UT_SQL.h.

const UT_StringHolder& UT_SqlStatement::blobTypeString ( ) const
inline

Definition at line 639 of file UT_SQL.h.

const UT_StringHolder& UT_SqlStatement::boolTypeString ( ) const
inline

Definition at line 647 of file UT_SQL.h.

int UT_SqlStatement::changes ( ) const
inline

Definition at line 883 of file UT_SQL.h.

NO_DISCARD const void* UT_SqlStatement::columnAsBlob ( int  idx,
int size 
) const
inline

Definition at line 519 of file UT_SQL.h.

NO_DISCARD Blob UT_SqlStatement::columnAsBlob ( int  idx) const
inline

Definition at line 523 of file UT_SQL.h.

NO_DISCARD bool UT_SqlStatement::columnAsBool ( int  idx) const
inline

Definition at line 496 of file UT_SQL.h.

NO_DISCARD UT_DateTimeField UT_SqlStatement::columnAsDate ( int  idx) const
inline

Definition at line 514 of file UT_SQL.h.

NO_DISCARD double UT_SqlStatement::columnAsDouble ( int  idx) const
inline

Definition at line 508 of file UT_SQL.h.

NO_DISCARD int UT_SqlStatement::columnAsInt ( int  idx) const
inline

Definition at line 492 of file UT_SQL.h.

NO_DISCARD int64 UT_SqlStatement::columnAsInt64 ( int  idx) const
inline

Definition at line 500 of file UT_SQL.h.

NO_DISCARD UT_Int64Array UT_SqlStatement::columnAsInt64Array ( int  idx) const
NO_DISCARD UT_IntArray UT_SqlStatement::columnAsIntArray ( int  idx) const
NO_DISCARD null_tag_t UT_SqlStatement::columnAsNull ( int  idx) const
inline

Definition at line 527 of file UT_SQL.h.

NO_DISCARD UT_StringHolder UT_SqlStatement::columnAsStr ( int  idx) const
inline

Definition at line 504 of file UT_SQL.h.

NO_DISCARD int UT_SqlStatement::columnBytes ( int  idx) const
inline

Definition at line 543 of file UT_SQL.h.

NO_DISCARD int UT_SqlStatement::columnCount ( ) const
inline

Definition at line 535 of file UT_SQL.h.

NO_DISCARD UT_StringHolder UT_SqlStatement::columnName ( int  idx) const
inline

Definition at line 531 of file UT_SQL.h.

NO_DISCARD DataType UT_SqlStatement::columnType ( int  idx) const
inline

Definition at line 539 of file UT_SQL.h.

const UT_StringHolder& UT_SqlStatement::dateTimeTypeString ( ) const
inline

Definition at line 643 of file UT_SQL.h.

template<typename... Args>
UT_SqlResult UT_SqlStatement::execute ( const UT_StringRef sql,
Args &&...  args 
)
inline

Helper function to create a new statement to run a new sql statement.

Definition at line 712 of file UT_SQL.h.

template<typename... Args>
UT_SqlResult UT_SqlStatement::execute ( const UT_SqlStatementHandleId id,
const UT_StringRef sql,
Args &&...  args 
)
inline

Helper function to create a new statement to run a new sql statement.

Definition at line 728 of file UT_SQL.h.

template<typename... Args>
UT_SqlResult UT_SqlStatement::executePrepared ( Args &&...  args)
inline

Definition at line 746 of file UT_SQL.h.

template<typename... Args>
UT_Array<std::tuple<Args...> > UT_SqlStatement::fetchAll ( UT_ErrorCode ec = nullptr)
inline

Definition at line 789 of file UT_SQL.h.

template<typename T >
UT_Array<T> UT_SqlStatement::fetchAllFlat ( UT_ErrorCode ec = nullptr)
inline

Definition at line 824 of file UT_SQL.h.

template<typename... Args>
std::optional<std::tuple<Args...> > UT_SqlStatement::fetchOne ( UT_ErrorCode ec = nullptr)
inline

Move to the next row

Definition at line 755 of file UT_SQL.h.

template<class... Args, std::size_t... Idxs>
std::tuple<Args...> UT_SqlStatement::fetchRow_ ( std::index_sequence< Idxs...>  )
inlineprotected

Definition at line 903 of file UT_SQL.h.

template<typename T >
T UT_SqlStatement::get ( int  idx) const
inline

Definition at line 653 of file UT_SQL.h.

template<>
double UT_SqlStatement::get ( int  idx) const
inline

Definition at line 918 of file UT_SQL.h.

template<>
UT_StringHolder UT_SqlStatement::get ( int  idx) const
inline

Definition at line 932 of file UT_SQL.h.

template<>
int UT_SqlStatement::get ( int  idx) const
inline

Definition at line 939 of file UT_SQL.h.

template<>
int64 UT_SqlStatement::get ( int  idx) const
inline

Definition at line 946 of file UT_SQL.h.

template<>
bool UT_SqlStatement::get ( int  idx) const
inline

Definition at line 953 of file UT_SQL.h.

template<>
UT_DateTimeField UT_SqlStatement::get ( int  idx) const
inline

Definition at line 960 of file UT_SQL.h.

template<>
const void* UT_SqlStatement::get ( int  idx) const
inline

Definition at line 967 of file UT_SQL.h.

const UT_ErrorCode& UT_SqlStatement::getError ( ) const
inline

Definition at line 701 of file UT_SQL.h.

bool UT_SqlStatement::hasRow ( )
inline

Definition at line 683 of file UT_SQL.h.

const UT_StringHolder& UT_SqlStatement::intTypeString ( ) const
inline

Definition at line 619 of file UT_SQL.h.

bool UT_SqlStatement::isImplEqual ( const UT_SqlStatement rhs) const
inline

Definition at line 885 of file UT_SQL.h.

NO_DISCARD bool UT_SqlStatement::isValid ( ) const
inline

Definition at line 678 of file UT_SQL.h.

const UT_StringHolder& UT_SqlStatement::nullTypeString ( ) const
inline

Definition at line 631 of file UT_SQL.h.

UT_SqlStatement& UT_SqlStatement::operator= ( UT_SqlStatement &&  )
delete
bool UT_SqlStatement::prepare ( const UT_StringRef sql,
UT_ErrorCode ec 
)
bool UT_SqlStatement::prepare ( const UT_SqlStatementHandleId id,
const UT_StringRef sql,
UT_ErrorCode ec 
)
const UT_StringHolder& UT_SqlStatement::realTypeString ( ) const
inline

Definition at line 635 of file UT_SQL.h.

void UT_SqlStatement::reset ( bool  clear_bindings = false)
inline

Definition at line 487 of file UT_SQL.h.

bool UT_SqlStatement::run ( )
inline

Definition at line 689 of file UT_SQL.h.

const char* UT_SqlStatement::sql ( ) const
inline

Definition at line 549 of file UT_SQL.h.

bool UT_SqlStatement::step ( )
inline

Definition at line 694 of file UT_SQL.h.

const UT_StringHolder& UT_SqlStatement::stringTypeString ( ) const
inline

Definition at line 627 of file UT_SQL.h.

NO_DISCARD bool UT_SqlStatement::tableExists ( const UT_StringRef name,
UT_ErrorCode ec = nullptr 
) const
inline

Definition at line 877 of file UT_SQL.h.

UT_SqlStatement::UT_NON_COPYABLE ( UT_SqlStatement  )

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