NCBI C++ ToolKit
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
CCallableStatement Class Reference

Search Toolkit Book for CCallableStatement

#include "cstmt_impl.hpp"
(Private to src/dbapi.)

+ Inheritance diagram for CCallableStatement:
+ Collaboration diagram for CCallableStatement:

Public Member Functions

 CCallableStatement (const string &proc, CConnection *conn)
 
virtual ~CCallableStatement ()
 
virtual bool HasMoreResults ()
 Check for more results available. More...
 
virtual int GetReturnStatus ()
 Get return status from the stored procedure. More...
 
virtual void SetParam (const CVariant &v, const CDBParamVariant &param)
 Set input parameters. More...
 
virtual void SetOutputParam (const CVariant &v, const CDBParamVariant &param)
 Set output parameter, which will be returned as resultset. More...
 
virtual void Execute ()
 Execute stored procedure. More...
 
virtual void ExecuteUpdate ()
 Executes stored procedure no results returned. More...
 
virtual void Close ()
 Close statement. More...
 
- Public Member Functions inherited from CStatement
 CStatement (class CConnection *conn)
 
virtual ~CStatement ()
 
virtual IResultSetGetResultSet ()
 Get resulset. 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 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 ClearParamList ()
 Clear parameter list. More...
 
virtual const IResultSetMetaDataGetParamsMetaData (void)
 Get input parameters metadata. More...
 
virtual IConnectionGetParentConn ()
 Get the parent connection. More...
 
virtual IWriterGetBlobWriter (I_BlobDescriptor &d, size_t blob_size, TBlobOStreamFlags flags)
 Get a writer for writing BLOBs using previously created CDB_BlobDescriptor. More...
 
virtual IWriterGetBlobWriter (I_BlobDescriptor &d, size_t blob_size, EAllowLog log_it)
 
virtual CNcbiOstreamGetBlobOStream (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 CNcbiOstreamGetBlobOStream (I_BlobDescriptor &d, size_t blob_size, EAllowLog log_it, size_t buf_size)
 
CConnectionGetConnection ()
 
CDB_ResultGetCDB_Result ()
 
CDB_LangCmdGetLangCmd ()
 
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...
 
- Public Member Functions inherited from CActiveObject
 CActiveObject ()
 
virtual ~CActiveObject ()
 
void AddListener (CActiveObject *obj)
 
void RemoveListener (CActiveObject *obj)
 
void Notify (const CDbapiEvent &e)
 
string GetIdent () const
 
- Public Member Functions inherited from IEventListener
virtual ~IEventListener ()
 
- Public Member Functions inherited from IStatement
virtual ~IStatement ()
 Destructor. More...
 
- Public Member Functions inherited from ICallableStatement
virtual ~ICallableStatement ()
 Destructor. More...
 

Protected Member Functions

CDB_RPCCmdGetRpcCmd ()
 
virtual void SendSql (const string &)
 Sends one or more SQL statements to the SQL server. More...
 
virtual void Execute (const string &)
 Sends one or more SQL statements to the SQL server (NOTE: replaced by the SendSql()) More...
 
virtual void ExecuteUpdate (const string &)
 Executes SQL statement with no results returned. More...
 
virtual IResultSetExecuteQuery (const string &)
 Exectues SQL statement and returns the first resultset. More...
 
- Protected Member Functions inherited from CStatement
void x_Send (const string &sql)
 
void SetBaseCmd (I_BaseCmd *cmd)
 
I_BaseCmdGetBaseCmd ()
 
void CacheResultSet (CDB_Result *rs)
 
void SetFailed (bool f)
 
void FreeResources ()
 
- Protected Member Functions inherited from CActiveObject
void SetIdent (const string &name)
 
TLListGetListenerList ()
 
- Protected Member Functions inherited from IEventListener
 IEventListener ()
 

Private Attributes

int m_status
 
bool m_StatusIsAvailable
 

Additional Inherited Members

- Protected Types inherited from CActiveObject
typedef list< CActiveObject * > TLList
 

Detailed Description

Definition at line 43 of file cstmt_impl.hpp.

Constructor & Destructor Documentation

◆ CCallableStatement()

CCallableStatement::CCallableStatement ( const string proc,
CConnection conn 
)

Definition at line 47 of file cstmt_impl.cpp.

References conn, proc, CStatement::SetBaseCmd(), and CActiveObject::SetIdent().

◆ ~CCallableStatement()

CCallableStatement::~CCallableStatement ( )
virtual

Definition at line 57 of file cstmt_impl.cpp.

References kEmptyStr, NCBI_CATCH_ALL_X, and CActiveObject::Notify().

Member Function Documentation

◆ Close()

void CCallableStatement::Close ( )
virtual

Close statement.

Reimplemented from CStatement.

Definition at line 160 of file cstmt_impl.cpp.

References CStatement::FreeResources(), and CActiveObject::Notify().

◆ Execute() [1/2]

void CCallableStatement::Execute ( )
virtual

◆ Execute() [2/2]

virtual void CCallableStatement::Execute ( const string sql)
inlineprotectedvirtual

Sends one or more SQL statements to the SQL server (NOTE: replaced by the SendSql())

Parameters
sqlSQL statement to execute.
Deprecated:
Use SendSql() instead

Reimplemented from ICallableStatement.

Definition at line 69 of file cstmt_impl.hpp.

◆ ExecuteQuery()

virtual IResultSet* CCallableStatement::ExecuteQuery ( const string sql)
inlineprotectedvirtual

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.

Parameters
sqlSQL statement to execute.
Returns
Pointer to result set. Ownership of IResultSet* belongs to IStatement. It is not allowed to use unique_ptr<> or other smart pointers to manage life-time of IResultSet*.

Reimplemented from ICallableStatement.

Definition at line 71 of file cstmt_impl.hpp.

◆ ExecuteUpdate() [1/2]

void CCallableStatement::ExecuteUpdate ( )
virtual

Executes stored procedure no results returned.

NOTE: All resultsets are discarded.

Implements ICallableStatement.

Definition at line 139 of file cstmt_impl.cpp.

References Execute(), and CStatement::PurgeResults().

◆ ExecuteUpdate() [2/2]

virtual void CCallableStatement::ExecuteUpdate ( const string sql)
inlineprotectedvirtual

Executes SQL statement with no results returned.

All resultsets are discarded.

Parameters
sqlSQL statement to execute.

Reimplemented from ICallableStatement.

Definition at line 70 of file cstmt_impl.hpp.

◆ GetReturnStatus()

int CCallableStatement::GetReturnStatus ( )
virtual

Get return status from the stored procedure.

Implements ICallableStatement.

Definition at line 146 of file cstmt_impl.cpp.

References CHECK_NCBI_DBAPI, m_status, and m_StatusIsAvailable.

◆ GetRpcCmd()

CDB_RPCCmd * CCallableStatement::GetRpcCmd ( )
protected

Definition at line 65 of file cstmt_impl.cpp.

References CStatement::GetBaseCmd().

Referenced by Execute(), SetOutputParam(), and SetParam().

◆ HasMoreResults()

bool CCallableStatement::HasMoreResults ( )
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.

Returns
Return true, if there are more results available.

Reimplemented from CStatement.

Definition at line 70 of file cstmt_impl.cpp.

References _TRACE, eDB_StatusResult, CStatement::GetCDB_Result(), CDB_Result::GetItem(), CStatement::HasMoreResults(), m_status, m_StatusIsAvailable, and CDB_Int::Value().

◆ SendSql()

virtual void CCallableStatement::SendSql ( const string sql)
inlineprotectedvirtual

Sends one or more SQL statements to the SQL server.

Parameters
sqlSQL statement to execute.

Reimplemented from ICallableStatement.

Definition at line 68 of file cstmt_impl.hpp.

◆ SetOutputParam()

void CCallableStatement::SetOutputParam ( const CVariant v,
const CDBParamVariant param 
)
virtual

Set output parameter, which will be returned as resultset.

NOTE: Use CVariant(EDB_Type type) constructor or factory method CVariant::<type>(0) to create empty object of a particular type.

Parameters
vParameter value.
nameParameter name.

Implements ICallableStatement.

Definition at line 110 of file cstmt_impl.cpp.

References CDB_RPCCmd::GetBindParams(), CVariant::GetData(), CDBParamVariant::GetPosition(), GetRpcCmd(), CDBParamVariant::IsPositional(), and CDBParams::Set().

◆ SetParam()

void CCallableStatement::SetParam ( const CVariant v,
const CDBParamVariant param 
)
virtual

Set input parameters.

Parameters
vParameter value.
nameParameter name.

Implements ICallableStatement.

Definition at line 99 of file cstmt_impl.cpp.

References CDB_RPCCmd::GetBindParams(), CVariant::GetData(), CDBParamVariant::GetPosition(), GetRpcCmd(), CDBParamVariant::IsPositional(), and CDBParams::Set().

Member Data Documentation

◆ m_status

int CCallableStatement::m_status
private

Definition at line 74 of file cstmt_impl.hpp.

Referenced by Execute(), GetReturnStatus(), and HasMoreResults().

◆ m_StatusIsAvailable

bool CCallableStatement::m_StatusIsAvailable
private

Definition at line 75 of file cstmt_impl.hpp.

Referenced by Execute(), GetReturnStatus(), and HasMoreResults().


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:57:09 2024 by modify_doxy.py rev. 669887