C++ Client API 1.4 (November 2023)
 
Loading...
Searching...
No Matches
dbSpaces::dbcli::Statement Class Reference

#include <Ccdb_Statement.h>

Inheritance diagram for dbSpaces::dbcli::Statement:
Collaboration diagram for dbSpaces::dbcli::Statement:

Public Member Functions

virtual ~Statement ()
 
void AddBatch ()
 
void AddBatch (const dtSTRING *SQLStatement)
 
dtRtnStatus BindInputParameter (dtLARGE, const dtSTRING *, dtTINY *=NULL)
 
dtRtnStatus BindInputParameter (dtLARGE, void *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindInputParameter (dtLARGE, void *, dtULARGE, dtUTINY, dtTINY *=NULL)
 
template<class T >
dtRtnStatus BindInputParameter (dtLARGE number, T &value, dtTINY *indicator=NULL)
 
dtRtnStatus BindInOutParameter (dtLARGE, dtSTRING *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindInOutParameter (dtLARGE, dtUSTRING *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindInOutParameter (dtLARGE, void *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindInOutParameter (dtLARGE, void *, dtULARGE, dtUTINY, dtTINY *=NULL)
 
template<class T >
dtRtnStatus BindInOutParameter (dtLARGE number, T &value, dtTINY *indicator=NULL)
 
dtRtnStatus BindOutputParameter (dtLARGE, dtSTRING *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindOutputParameter (dtLARGE, dtUSTRING *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindOutputParameter (dtLARGE, void *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindOutputParameter (dtLARGE, void *, dtULARGE, dtUTINY, dtTINY *=NULL)
 
template<class T >
dtRtnStatus BindOutputParameter (dtLARGE number, T &value, dtTINY *indicator=NULL)
 
dtRtnStatus BindReturnParameter (dtLARGE, dtSTRING *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindReturnParameter (dtLARGE, dtUSTRING *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindReturnParameter (dtLARGE, void *, dtULARGE, dtTINY *=NULL)
 
dtRtnStatus BindReturnParameter (dtLARGE, void *, dtULARGE, dtUTINY, dtTINY *=NULL)
 
template<class T >
dtRtnStatus BindReturnParameter (dtLARGE number, T &value, dtTINY *indicator=NULL)
 
dtRtnStatus Cancel ()
 
void ClearBatch ()
 
void Close ()
 
ResultSetExecute ()
 
cdbBatchRowCount_t * ExecuteBatch ()
 
ResultSetExecDirect (dtSTRING *)
 
dtULARGE GetFetchSize ()
 
dtULARGE GetMaxRows ()
 
const dtSTRING * GetName ()
 
dtLARGE GetNumberParameters ()
 
dtULARGE GetNumberResultColumns ()
 
dtLARGE GetRowCount ()
 
dtBOOLEAN IsOpen ()
 
ResultSetMoreResults ()
 
dtRtnStatus Prepare (dtSTRING const *)
 
dtRtnStatus SetFetchSize (dtULARGE)
 
dtRtnStatus SetMaxRows (dtULARGE)
 
dtRtnStatus SetName (const dtSTRING *)
 
void UnbindParameters ()
 
- Public Member Functions inherited from dbSpaces::dbcli::cdbBase
 cdbBase (cdbBase *, ccdbClassType, dtBOOLEAN=TRUE)
 
virtual ~cdbBase ()
 
cdb_childList_t & GetChildList ()
 
Ccoms_CommsManager * GetTransportComms ()
 
ccdbClassType GetType ()
 
void SetTransportComms (Ccoms_CommsManager *)
 

Protected Member Functions

 Statement ()
 

Detailed Description

A Statement object is used for executing a static/dynamic SQL statement and obtaining the results produced by it.

Only one ResultSet per Statement can be open at any point in time. Therefore, if the reading of one ResultSet is interleaved with the reading of another, each must have been generated by different Statements. All statement execute methods implicitly close a statment's current ResultSet if an open one exists.

A DatabaseException will be thrown if a database error occurs and exceptions are enabled. If exceptions are not enabled the following error methods can be used to get information about the error;

  • GetErrorStatus()
  • GetErrorCode()
  • GetErrorMessage()
See also
Connection::createStatement
ResultSet
Since
Version 1.0

Constructor & Destructor Documentation

◆ Statement()

dbSpaces::dbcli::Statement::Statement ( )
protected

Statement default constructor.

Since
Version 1.0

◆ ~Statement()

virtual dbSpaces::dbcli::Statement::~Statement ( )
virtual

Statement default destructor. If the statement is still open the destructor will automatically stop execution and close it.

See also
Cancel() and Close().
Since
Version 1.0

Member Function Documentation

◆ AddBatch() [1/2]

void dbSpaces::dbcli::Statement::AddBatch ( )

Allows a new dynamic statement to be added to a SQL Batch of statements. After calling this method call Prepare() to setup the next batch SQL statement.

See also
ExecuteBatch();
Since
Version 1.0

◆ AddBatch() [2/2]

void dbSpaces::dbcli::Statement::AddBatch ( const dtSTRING *  SQLStatement)

Allows a new static SQL statement to be added to the SQL Batch.

Parameters
SQLStatementThe SQL Statement to add to batch.
See also
ClearBatch() and ExecuteBatch()
Since
Version 1.0

◆ BindInOutParameter() [1/5]

template<class T >
template< class T > dtRtnStatus dbSpaces::dbcli::Statement::BindInOutParameter ( dtLARGE  number,
T &  value,
dtTINY *  indicator = NULL 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindInOutParameter() [2/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindInOutParameter ( dtLARGE  ,
dtSTRING *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

Bind a program's local variable as a dynamic parameter for both input and output.

Parameters
numberThe first parameter is 1, the second is 2, ...
valueValue address.
indicatorIndicator(s) address used to indicate NOT NULL or NULL data.
Possible indicator values are;
  • 1 - (CTYPE_NOT_NULL) not null data.
  • 2 - (CTYPE_NULL) null data.
Note
The indicator parameter is optional.
Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Since
Version 1.0

◆ BindInOutParameter() [3/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindInOutParameter ( dtLARGE  ,
dtUSTRING *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindInOutParameter() [4/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindInOutParameter ( dtLARGE  ,
void *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindInOutParameter() [5/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindInOutParameter ( dtLARGE  ,
void *  ,
dtULARGE  ,
dtUTINY  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindInputParameter() [1/4]

template<class T >
template< class T > dtRtnStatus dbSpaces::dbcli::Statement::BindInputParameter ( dtLARGE  number,
T &  value,
dtTINY *  indicator = NULL 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindInputParameter() [2/4]

dtRtnStatus dbSpaces::dbcli::Statement::BindInputParameter ( dtLARGE  ,
const dtSTRING *  ,
dtTINY *  = NULL 
)

Bind a program's local variable as a dynamic parameter for input only.

Parameters
numberThe first parameter is 1, the second is 2, ...
valueValue(s) address.
indicatorIndicator(s) address used to indicate NOT NULL or NULL data.
Possible indicator values are;
  • 1 - (CTYPE_NOT_NULL) not null data.
  • 2 - (CTYPE_NULL) null data.
Note
The indicator parameter is optional.
Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Since
Version 1.0

◆ BindInputParameter() [3/4]

dtRtnStatus dbSpaces::dbcli::Statement::BindInputParameter ( dtLARGE  ,
void *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindInputParameter() [4/4]

dtRtnStatus dbSpaces::dbcli::Statement::BindInputParameter ( dtLARGE  ,
void *  ,
dtULARGE  ,
dtUTINY  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindOutputParameter() [1/5]

template<class T >
template< class T > dtRtnStatus dbSpaces::dbcli::Statement::BindOutputParameter ( dtLARGE  number,
T &  value,
dtTINY *  indicator = NULL 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindOutputParameter() [2/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindOutputParameter ( dtLARGE  ,
dtSTRING *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

Bind a program's local variable as a dynamic parameter for output only.

Parameters
numberThe first parameter is 1, the second is 2, ...
valueValue address for output.
indicatorIndicator(s) address used to indicate NOT NULL or NULL data.
Possible indicator values are;
  • 1 - (CTYPE_NOT_NULL) not null data.
  • 2 - (CTYPE_NULL) null data.
Note
The indicator parameter is optional.
Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Since
Version 1.0

◆ BindOutputParameter() [3/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindOutputParameter ( dtLARGE  ,
dtUSTRING *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindOutputParameter() [4/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindOutputParameter ( dtLARGE  ,
void *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindOutputParameter() [5/5]

dbSpaces::dbcli::Statement::BindOutputParameter ( dtLARGE  ,
void *  ,
dtULARGE  ,
dtUTINY  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindReturnParameter() [1/5]

template<class T >
template dbSpaces::dbcli::Statement::BindReturnParameter ( dtLARGE  number,
T &  value,
dtTINY *  indicator = NULL 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindReturnParameter() [2/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindReturnParameter ( dtLARGE  ,
dtSTRING *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

Bind a program's local variable as a dynamic parameter for the return value.

Parameters
numberThe return parameter should be 1.
valueValue address for output.
indicatorIndicator(s) address used to indicate NOT NULL or NULL data.
Possible indicator values are;
  • 1 - (CTYPE_NOT_NULL) not null data.
  • 2 - (CTYPE_NULL) null data.
Note
The indicator parameter is optional.
Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Since
Version 1.0

◆ BindReturnParameter() [3/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindReturnParameter ( dtLARGE  ,
dtUSTRING *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindReturnParameter() [4/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindReturnParameter ( dtLARGE  ,
void *  ,
dtULARGE  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ BindReturnParameter() [5/5]

dtRtnStatus dbSpaces::dbcli::Statement::BindReturnParameter ( dtLARGE  ,
void *  ,
dtULARGE  ,
dtUTINY  ,
dtTINY *  = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
Version 1.0

◆ Cancel()

dtRtnStatus dbSpaces::dbcli::Statement::Cancel ( )

Cancel the execution of the statement.

Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
Since
Version 1.0

◆ ClearBatch()

void dbSpaces::dbcli::Statement::ClearBatch ( )

Clear out any existing batch statements.

See also
AddBatch()
Since
Version 1.0

◆ Close()

void dbSpaces::dbcli::Statement::Close ( )

Close the statement in the server. Frees any held resources locally and in the server.

Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
Since
Version 1.0

◆ ExecDirect()

ResultSet * dbSpaces::dbcli::Statement::ExecDirect ( dtSTRING *  )

Execute a SQL statement immediately without first preparing and then executing it.

Parameters
SQLStatementThe SQL statement to execute.
Returns
The ResultSet object.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
Since
Version 1.0

◆ Execute()

ResultSet * dbSpaces::dbcli::Statement::Execute ( )

Execute the prepared statement and return a ResultSet object.

Returns
ResultSet object if successful; otherwise null.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
See also
Prepare()
Since
Version 1.0

◆ ExecuteBatch()

cdbBatchRowCount_t * dbSpaces::dbcli::Statement::ExecuteBatch ( )

Execute the current batch of SQL statements. A List containing the rows processed for each statement executed is returned.

Returns
cdbBatchRowCount_tobject.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
See also
AddBatch()
Since
Version 1.0

◆ GetFetchSize()

dtULARGE dbSpaces::dbcli::Statement::GetFetchSize ( )

Get the fetch size for returning rows with the ResultSet object.

Returns
The fetch size.
See also
SetFetchSize().
Since
Version 1.0

◆ GetMaxRows()

dtULARGE dbSpaces::dbcli::Statement::GetMaxRows ( )

Get the maximum rows that can be returned for this Statement.

Returns
The maximum rows.
Since
Version 1.0

◆ GetName()

const dtSTRING * dbSpaces::dbcli::Statement::GetName ( )

Get the cursor name for the Statement.

Returns
The cursor name.
Since
Version 1.0

◆ GetNumberParameters()

dtLARGE dbSpaces::dbcli::Statement::GetNumberParameters ( )

Get the number of dynamic parameters for the current SQL statement.

Returns
The number of parameters.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
Since
Version 1.0

◆ GetNumberResultColumns()

dtULARGE dbSpaces::dbcli::Statement::GetNumberResultColumns ( )

Get the number of result columns in the ResultSet object.

Returns
The number of columns.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
Since
Version 1.0

◆ GetRowCount()

dtLARGE dbSpaces::dbcli::Statement::GetRowCount ( )

Get the row count for the number of rows processed for either an insert, delete or update request.

Returns
The number of rows processed.
Since
Version 1.0

◆ IsOpen()

dtBOOLEAN dbSpaces::dbcli::Statement::IsOpen ( )

Is the Statement open?

Returns
TRUE if open; FALSE if otherwise.
See also
Close().
Since
Version 1.0

◆ MoreResults()

ResultSet * dbSpaces::dbcli::Statement::MoreResults ( )

Return the next ResultSet object. If you have created batched queries and then this method allows you to get each ResultSet object.

Returns
The ResultSet object.
Since
Version 1.0

◆ Prepare()

dtRtnStatus dbSpaces::dbcli::Statement::Prepare ( dtSTRING const *  )

Prepares a SQL query so that it may be executed more than one.

Parameters
SQLStatementThe SQL Statement to prepare.
Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
See also
Execute()
Since
Version 1.0

◆ SetFetchSize()

dtRtnStatus dbSpaces::dbcli::Statement::SetFetchSize ( dtULARGE  )

Set the fetch size for the number of rows returned to the ResultSet object.

Parameters
sizeThe new fetch size.
Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
Since
Version 1.0

◆ SetMaxRows()

dtRtnStatus dbSpaces::dbcli::Statement::SetMaxRows ( dtULARGE  )

Set the maximum rows that can be returned from a query.

Parameters
maxRowsThe new maximum number of rows.
Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
Since
Version 1.0

◆ SetName()

dtRtnStatus dbSpaces::dbcli::Statement::SetName ( const dtSTRING *  )

Set the cursor name for the Statement. The name must be unique and not already exist for another Statement.

Parameters
cursorNameThe name for the cursor.
Returns
RTN_STATUS_SUCCESS or RTN_STATUS_ERROR.
Exceptions
DatabaseException(if exceptions are enabled) when a database error occurs.
Since
Version 1.0

◆ UnbindParameters()

void dbSpaces::dbcli::Statement::UnbindParameters ( )

Unbind any parameters that have been previously bound.

Since
Version 1.0