NCBI C++ ToolKit
|
Search Toolkit Book for CStatement
#include "stmt_impl.hpp"
(Private to src/dbapi
.)
Classes | |
class | CStmtParamsMetaData |
Public Member Functions | |
CStatement (class CConnection *conn) | |
virtual | ~CStatement () |
virtual IResultSet * | GetResultSet () |
Get resulset. More... | |
virtual bool | HasMoreResults () |
Check for more results available. More... | |
virtual bool | HasRows () |
Check if resultset has rows. More... | |
virtual bool | Failed () |
Check if the statement failed. More... | |
virtual int | GetRowCount () |
Get total of rows returned. More... | |
virtual void | SendSql (const string &sql) |
Sends one or more SQL statements to the SQL server. More... | |
virtual void | Execute (const string &sql) |
Sends one or more SQL statements to the SQL server (NOTE: replaced by the SendSql()) More... | |
virtual void | ExecuteUpdate (const string &sql) |
Executes SQL statement with no results returned. More... | |
virtual IResultSet * | ExecuteQuery (const string &sql) |
Exectues SQL statement and returns the first resultset. More... | |
virtual void | ExecuteLast () |
Executes the last command (with changed parameters, if any). More... | |
virtual void | PurgeResults () |
Purge results. More... | |
virtual void | Cancel () |
Cancel statement. More... | |
virtual void | Close () |
Close statement. More... | |
virtual void | SetParam (const CVariant &v, const CDBParamVariant ¶m) |
Set input/output parameter. More... | |
virtual void | ClearParamList () |
Clear parameter list. More... | |
virtual const IResultSetMetaData & | GetParamsMetaData (void) |
Get input parameters metadata. More... | |
virtual IConnection * | GetParentConn () |
Get the parent connection. More... | |
virtual IWriter * | GetBlobWriter (I_BlobDescriptor &d, size_t blob_size, TBlobOStreamFlags flags) |
Get a writer for writing BLOBs using previously created CDB_BlobDescriptor. More... | |
virtual IWriter * | GetBlobWriter (I_BlobDescriptor &d, size_t blob_size, EAllowLog log_it) |
virtual CNcbiOstream & | GetBlobOStream (I_BlobDescriptor &d, size_t blob_size, TBlobOStreamFlags flags, size_t buf_size) |
Get an ostream for writing BLOBs using previously created CDB_BlobDescriptor. More... | |
virtual CNcbiOstream & | GetBlobOStream (I_BlobDescriptor &d, size_t blob_size, EAllowLog log_it, size_t buf_size) |
CConnection * | GetConnection () |
CDB_Result * | GetCDB_Result () |
CDB_LangCmd * | GetLangCmd () |
virtual void | Action (const CDbapiEvent &e) |
virtual void | SetAutoClearInParams (bool flag=true) |
Set auto-clear input parameter flag. More... | |
virtual bool | IsAutoClearInParams (void) const |
Get auto-clear input parameter flag value. More... | |
![]() | |
CActiveObject () | |
virtual | ~CActiveObject () |
void | AddListener (CActiveObject *obj) |
void | RemoveListener (CActiveObject *obj) |
void | Notify (const CDbapiEvent &e) |
string | GetIdent () const |
![]() | |
virtual | ~IEventListener () |
![]() | |
virtual | ~IStatement () |
Destructor. More... | |
Protected Member Functions | |
void | x_Send (const string &sql) |
void | SetBaseCmd (I_BaseCmd *cmd) |
I_BaseCmd * | GetBaseCmd () |
void | CacheResultSet (CDB_Result *rs) |
void | SetFailed (bool f) |
void | FreeResources () |
![]() | |
void | SetIdent (const string &name) |
TLList & | GetListenerList () |
![]() | |
IEventListener () | |
Private Types | |
typedef map< string, CVariant * > | ParamList |
typedef vector< CVariant * > | ParamByPosList |
Private Attributes | |
class CConnection * | m_conn |
I_BaseCmd * | m_cmd |
CStmtParamsMetaData | m_InParams |
int | m_rowCount |
bool | m_failed |
ParamList | m_params |
ParamByPosList | m_posParams |
class CResultSet * | m_irs |
class IWriter * | m_wr |
class CWStream * | m_ostr |
bool | m_AutoClearInParams |
Additional Inherited Members | |
![]() | |
typedef list< CActiveObject * > | TLList |
Definition at line 46 of file stmt_impl.hpp.
|
private |
Definition at line 156 of file stmt_impl.hpp.
|
private |
Definition at line 155 of file stmt_impl.hpp.
CStatement::CStatement | ( | class CConnection * | conn | ) |
Definition at line 94 of file stmt_impl.cpp.
References CActiveObject::SetIdent().
|
virtual |
Definition at line 108 of file stmt_impl.cpp.
References _TRACE, FreeResources(), CActiveObject::GetIdent(), kEmptyStr, NCBI_CATCH_ALL_X, and CActiveObject::Notify().
|
virtual |
Reimplemented from CActiveObject.
Definition at line 396 of file stmt_impl.cpp.
References _TRACE, CActiveObject::GetIdent(), CDbapiEvent::GetName(), CDbapiEvent::GetSource(), CResultSet::GetTotalRows(), m_irs, m_rowCount, and CActiveObject::RemoveListener().
|
protected |
Definition at line 124 of file stmt_impl.cpp.
References _TRACE, CActiveObject::AddListener(), CResultSet::Invalidate(), m_conn, and m_irs.
Referenced by HasMoreResults().
|
virtual |
Cancel statement.
Rolls back current transaction.
Implements IStatement.
Definition at line 381 of file stmt_impl.cpp.
References I_BaseCmd::Cancel(), GetBaseCmd(), and m_rowCount.
|
virtual |
Clear parameter list.
Implements IStatement.
Definition at line 204 of file stmt_impl.cpp.
References map_checker< Container >::begin(), map_checker< Container >::clear(), map_checker< Container >::end(), i, m_params, and m_posParams.
Referenced by CCallableStatement::Execute(), FreeResources(), and x_Send().
|
virtual |
Close statement.
Implements IStatement.
Reimplemented in CCallableStatement.
Definition at line 338 of file stmt_impl.cpp.
References FreeResources(), and CActiveObject::Notify().
Sends one or more SQL statements to the SQL server (NOTE: replaced by the SendSql())
sql | SQL statement to execute. |
Implements IStatement.
Reimplemented in CCallableStatement.
Definition at line 217 of file stmt_impl.cpp.
|
virtual |
Executes the last command (with changed parameters, if any).
Implements IStatement.
Definition at line 268 of file stmt_impl.cpp.
References map_checker< Container >::begin(), CDBParams::Bind(), map_checker< Container >::end(), CDB_LangCmd::GetBindParams(), CVariant::GetData(), GetLangCmd(), i, m_cmd, m_params, m_posParams, NCBI_DBAPI_THROW, and I_BaseCmd::Send().
Referenced by x_Send().
|
virtual |
Exectues SQL statement and returns the first resultset.
If there is more than one resultset, the rest remain pending unless either PurgeResults() is called or next statement is run or the statement is closed. NOTE: Provided only for queries containing a single sql statement returning rows.
sql | SQL statement to execute. |
Implements IStatement.
Reimplemented in CCallableStatement.
Definition at line 247 of file stmt_impl.cpp.
References Failed(), GetResultSet(), HasMoreResults(), HasRows(), NCBI_DBAPI_THROW, SendSql(), and sql.
Executes SQL statement with no results returned.
All resultsets are discarded.
sql | SQL statement to execute. |
Implements IStatement.
Reimplemented in CCallableStatement.
Definition at line 261 of file stmt_impl.cpp.
References PurgeResults(), SendSql(), and sql.
|
virtual |
Check if the statement failed.
Implements IStatement.
Definition at line 322 of file stmt_impl.cpp.
References m_failed.
Referenced by ExecuteQuery().
|
protected |
Definition at line 344 of file stmt_impl.cpp.
References ClearParamList(), CConnection::IsAux(), m_cmd, m_conn, m_ostr, m_rowCount, m_wr, and CActiveObject::Notify().
Referenced by CCallableStatement::Close(), Close(), and ~CStatement().
|
inlineprotected |
Definition at line 124 of file stmt_impl.hpp.
References m_cmd.
Referenced by Cancel(), GetRowCount(), CCallableStatement::GetRpcCmd(), and HasMoreResults().
|
inlinevirtual |
Reimplemented from IStatement.
Definition at line 93 of file stmt_impl.hpp.
References IStatement::GetBlobOStream().
|
virtual |
Get an ostream for writing BLOBs using previously created CDB_BlobDescriptor.
d | Descriptor |
blob_size | Size of BLOB to write |
flags |
buf_size | Buffer size, default 4096 |
Implements IStatement.
Definition at line 304 of file stmt_impl.cpp.
References flags, CRWStreambuf::fLogExceptions, CRWStreambuf::fOwnWriter, GetConnection(), and m_ostr.
|
inlinevirtual |
Reimplemented from IStatement.
Definition at line 83 of file stmt_impl.hpp.
References IStatement::GetBlobWriter().
|
virtual |
Get a writer for writing BLOBs using previously created CDB_BlobDescriptor.
d | Descriptor |
blob_size | Size of BLOB to write |
flags |
Implements IStatement.
Definition at line 294 of file stmt_impl.cpp.
References flags, GetConnection(), and m_wr.
CDB_Result * CStatement::GetCDB_Result | ( | ) |
Definition at line 317 of file stmt_impl.cpp.
References CResultSet::GetCDB_Result(), and m_irs.
Referenced by CCallableStatement::HasMoreResults().
|
inline |
Definition at line 101 of file stmt_impl.hpp.
References m_conn.
Referenced by GetBlobOStream(), and GetBlobWriter().
CDB_LangCmd * CStatement::GetLangCmd | ( | ) |
|
virtual |
Get input parameters metadata.
Implements IStatement.
Definition at line 284 of file stmt_impl.cpp.
References m_InParams.
|
virtual |
Get the parent connection.
If the original connections was cloned, returns cloned connection.
Implements IStatement.
Definition at line 119 of file stmt_impl.cpp.
References m_conn.
|
virtual |
Get resulset.
Implements IStatement.
Definition at line 142 of file stmt_impl.cpp.
References m_irs.
Referenced by ExecuteQuery(), and PurgeResults().
|
virtual |
Get total of rows returned.
Valid only after all rows are retrieved from a resultset. Even then, can be -1 if the server didn't indicate a count.
Implements IStatement.
Definition at line 327 of file stmt_impl.cpp.
References GetBaseCmd(), and m_rowCount.
|
virtual |
Check for more results available.
Each call advances to the next result and the current one will be cancelled it not retrieved before next call. The amount of retured results may be bigger than the expected amount due to auxiliary results returned depending on the driver and server platform.
Implements IStatement.
Reimplemented in CCallableStatement.
Definition at line 147 of file stmt_impl.cpp.
References CacheResultSet(), GetBaseCmd(), I_BaseCmd::HasMoreResults(), m_rowCount, NULL, I_BaseCmd::Result(), I_BaseCmd::RowCount(), and SetFailed().
Referenced by ExecuteQuery(), CCallableStatement::HasMoreResults(), and PurgeResults().
|
virtual |
Check if resultset has rows.
Implements IStatement.
Definition at line 289 of file stmt_impl.cpp.
References m_irs.
Referenced by ExecuteQuery(), and PurgeResults().
|
inlinevirtual |
Get auto-clear input parameter flag value.
Implements IStatement.
Definition at line 117 of file stmt_impl.hpp.
References m_AutoClearInParams.
Referenced by CCallableStatement::Execute(), and x_Send().
|
virtual |
Purge results.
Calls fetch for every resultset received until finished.
Implements IStatement.
Definition at line 364 of file stmt_impl.cpp.
References GetResultSet(), HasMoreResults(), HasRows(), and m_irs.
Referenced by CCallableStatement::ExecuteUpdate(), and ExecuteUpdate().
Sends one or more SQL statements to the SQL server.
sql | SQL statement to execute. |
Implements IStatement.
Reimplemented in CCallableStatement.
Definition at line 222 of file stmt_impl.cpp.
Referenced by ExecuteQuery(), and ExecuteUpdate().
Set auto-clear input parameter flag.
flag | auto-clear input parameter flag In case when flag == true implicitly clear a statement's parameter list after each Execute, ExecuteUpdate and ExecuteQuery call. Default value |
Implements IStatement.
Definition at line 114 of file stmt_impl.hpp.
References m_AutoClearInParams.
|
inlineprotected |
Definition at line 123 of file stmt_impl.hpp.
Referenced by CCallableStatement::CCallableStatement().
|
inlineprotected |
Definition at line 128 of file stmt_impl.hpp.
Referenced by CCallableStatement::Execute(), HasMoreResults(), and x_Send().
|
virtual |
Set input/output parameter.
v | Parameter value. |
name | Parameter name. |
Implements IStatement.
Reimplemented in CCallableStatement.
Definition at line 174 of file stmt_impl.cpp.
References map_checker< Container >::empty(), map_checker< Container >::end(), map_checker< Container >::find(), CDBParamVariant::GetName(), CDBParamVariant::GetPosition(), i, map_checker< Container >::insert(), CDBParamVariant::IsPositional(), m_params, m_posParams, and NCBI_DBAPI_THROW.
Definition at line 227 of file stmt_impl.cpp.
References ClearParamList(), ExecuteLast(), CConnection::GetCDB_Connection(), IsAutoClearInParams(), CDB_Connection::LangCmd(), m_cmd, m_conn, m_rowCount, SetFailed(), and sql.
|
private |
Definition at line 168 of file stmt_impl.hpp.
Referenced by IsAutoClearInParams(), and SetAutoClearInParams().
|
private |
Definition at line 159 of file stmt_impl.hpp.
Referenced by ExecuteLast(), FreeResources(), GetBaseCmd(), GetLangCmd(), SetBaseCmd(), and x_Send().
|
private |
Definition at line 158 of file stmt_impl.hpp.
Referenced by CacheResultSet(), FreeResources(), GetConnection(), GetParentConn(), and x_Send().
|
private |
Definition at line 162 of file stmt_impl.hpp.
Referenced by Failed(), and SetFailed().
|
private |
Definition at line 160 of file stmt_impl.hpp.
Referenced by GetParamsMetaData().
|
private |
Definition at line 165 of file stmt_impl.hpp.
Referenced by Action(), CacheResultSet(), GetCDB_Result(), GetResultSet(), HasRows(), and PurgeResults().
|
private |
Definition at line 167 of file stmt_impl.hpp.
Referenced by FreeResources(), and GetBlobOStream().
|
private |
Definition at line 163 of file stmt_impl.hpp.
Referenced by ClearParamList(), ExecuteLast(), and SetParam().
|
private |
Definition at line 164 of file stmt_impl.hpp.
Referenced by ClearParamList(), ExecuteLast(), and SetParam().
|
private |
Definition at line 161 of file stmt_impl.hpp.
Referenced by Action(), Cancel(), FreeResources(), GetRowCount(), HasMoreResults(), and x_Send().
|
private |
Definition at line 166 of file stmt_impl.hpp.
Referenced by FreeResources(), and GetBlobWriter().