OCILIB (C and C++ Driver for Oracle)
4.1.0
|
Object used for executing SQL or PL/SQL statement and returning the produced results. More...
#include <ocilib.hpp>
Inherits ocilib::HandleHolder< OCI_Statement * >.
Public Types | |
enum | StatementTypeValues { TypeSelect = OCI_CST_SELECT, TypeUpdate = OCI_CST_UPDATE, TypeDelete = OCI_CST_DELETE, TypeInsert = OCI_CST_INSERT, TypeCreate = OCI_CST_CREATE, TypeDrop = OCI_CST_DROP, TypeAlter = OCI_CST_ALTER, TypeBegin = OCI_CST_BEGIN, TypeDeclare = OCI_CST_DECLARE, TypeCall = OCI_CST_CALL } |
Statement Type enumerated values. More... | |
enum | FetchModeValues { FetchForward = OCI_SFM_DEFAULT, FetchScrollable = OCI_SFM_SCROLLABLE } |
Fetch Modes enumerated values. More... | |
enum | BindModeValues { BindByPosition = OCI_BIND_BY_POS, BindByName = OCI_BIND_BY_NAME } |
Bind Modes enumerated values. More... | |
enum | LongModeValues { LongExplicit = OCI_LONG_EXPLICIT, LongImplicit = OCI_LONG_IMPLICIT } |
LONG data type mapping modes enumerated values. More... | |
typedef Enum< StatementTypeValues > | StatementType |
Statement Type. More... | |
typedef Enum< FetchModeValues > | FetchMode |
Fetch Modes. More... | |
typedef Enum< BindModeValues > | BindMode |
Bind Modes. More... | |
typedef Enum< LongModeValues > | LongMode |
LONG data type mapping modes. More... | |
Public Member Functions | |
Statement () | |
Create an empty null Statement instance. | |
Statement (const Connection &connection) | |
Parametrized constructor. More... | |
~Statement () | |
Destructor. | |
Connection | GetConnection () const |
Return the connection associated with a statement. | |
void | Describe (const ostring &sql) |
Describe the select list of a SQL select statement. More... | |
void | Parse (const ostring &sql) |
Parse a SQL statement or PL/SQL block. More... | |
void | Prepare (const ostring &sql) |
Prepare a SQL statement or PL/SQL block. More... | |
void | ExecutePrepared () |
Execute a prepared SQL statement or PL/SQL block. | |
void | Execute (const ostring &sql) |
Prepare and execute a SQL statement or PL/SQL block. More... | |
template<class TFetchCallback > | |
unsigned int | ExecutePrepared (TFetchCallback callback) |
Execute the prepared statement, retrieve all resultsets, and call the given callback for each row of each resultsets. More... | |
template<class TAdapter , class TFetchCallback > | |
unsigned int | ExecutePrepared (TFetchCallback callback, TAdapter adapter) |
Execute the prepared statement, retrieve all resultsets, and call the given callback with adapted type wit for each row of each resultsets. More... | |
template<class TFetchCallback > | |
unsigned int | Execute (const ostring &sql, TFetchCallback callback) |
Execute the given SQL statement, retrieve all resultsets, and call the given callback for each row of each resultsets. More... | |
template<class TAdapter , class TFetchCallback > | |
unsigned int | Execute (const ostring &sql, TFetchCallback callback, TAdapter adapter) |
Execute the given SQL statement, retrieve all resultsets, and call the given callback with adapted type wit for each row of each resultsets. More... | |
unsigned int | GetAffectedRows () const |
Return the number of rows affected by the SQL statement. More... | |
ostring | GetSql () const |
Return the last SQL or PL/SQL statement prepared or executed by the statement. | |
Resultset | GetResultset () |
Retrieve the resultset from an executed statement. More... | |
Resultset | GetNextResultset () |
Retrieve the next available resultset. More... | |
void | SetBindArraySize (unsigned int size) |
Set the input array size for bulk operations. More... | |
unsigned int | GetBindArraySize () const |
Return the current input array size for bulk operations. | |
void | AllowRebinding (bool value) |
Allow different host variables to be binded using the same bind name or position between executions of a prepared statement. More... | |
bool | IsRebindingAllowed () const |
Indicate if rebinding is allowed on the statement. More... | |
unsigned int | GetBindIndex (const ostring &name) const |
Return the index of the bind from its name belonging to the statement. More... | |
unsigned int | GetBindCount () const |
Return the number of binds currently associated to a statement. | |
BindInfo | GetBind (unsigned int index) const |
Return the bind at the given index in the internal array of bind objects. More... | |
BindInfo | GetBind (const ostring &name) const |
Return a bind handle from its name. More... | |
template<class TDataType > | |
void | Bind (const ostring &name, TDataType &value, BindInfo::BindDirection mode) |
Bind an host variable. More... | |
template<class TDataType , class TExtraInfo > | |
void | Bind (const ostring &name, TDataType &value, TExtraInfo extraInfo, BindInfo::BindDirection mode) |
Bind an host variable with more information. More... | |
template<class TDataType > | |
void | Bind (const ostring &name, Collection< TDataType > &value, BindInfo::BindDirection mode) |
Bind a host collection variable. More... | |
template<class TDataType > | |
void | Bind (const ostring &name, std::vector< TDataType > &values, BindInfo::BindDirection mode) |
Bind a vector of host variables. More... | |
template<class TDataType > | |
void | Bind (const ostring &name, std::vector< TDataType > &values, TypeInfo &typeInfo, BindInfo::BindDirection mode) |
Bind a vector of host variables with Oracle type information. More... | |
template<class TDataType > | |
void | Bind (const ostring &name, std::vector< Collection< TDataType > > &values, TypeInfo &typeInfo, BindInfo::BindDirection mode) |
Bind a vector of host collection variables with Oracle type information. More... | |
template<class TDataType , class TExtraInfo > | |
void | Bind (const ostring &name, std::vector< TDataType > &values, TExtraInfo extraInfo, BindInfo::BindDirection mode) |
Bind a vector of host variables with more information. More... | |
template<class TDataType > | |
void | Register (const ostring &name) |
Register a host variable as an output for a column present in a SQL RETURNING INTO clause. More... | |
template<class TDataType , class TExtraInfo > | |
void | Register (const ostring &name, TExtraInfo &extraInfo) |
Register a host variable with Oracle type information as an output for a column present in a SQL RETURNING INTO clause. More... | |
template<class TDataType , class TExtraInfo > | |
void | Register (const ostring &name, TExtraInfo extraInfo) |
Register a host variable with more information as an output for a column present in a SQL RETURNING INTO clause. More... | |
StatementType | GetStatementType () const |
Return the type of a SQL statement. | |
unsigned int | GetSqlErrorPos () const |
Return the error position (in terms of characters) in the SQL statement where the error occurred in case of SQL parsing error. More... | |
void | SetFetchMode (FetchMode value) |
Set the fetch mode of a SQL statement. More... | |
FetchMode | GetFetchMode () const |
Return the fetch mode of a SQL statement. More... | |
void | SetBindMode (BindMode value) |
Set the binding mode of a SQL statement. More... | |
BindMode | GetBindMode () const |
Return the binding mode of a SQL statement. More... | |
void | SetFetchSize (unsigned int value) |
Set the number of rows fetched per internal server fetch call. More... | |
unsigned int | GetFetchSize () const |
Return the number of rows fetched per internal server fetch call. More... | |
void | SetPrefetchSize (unsigned int value) |
Set the number of rows pre-fetched by OCI Client. More... | |
unsigned int | GetPrefetchSize () const |
Return the number of rows pre-fetched by OCI Client. More... | |
void | SetPrefetchMemory (unsigned int value) |
Set the amount of memory pre-fetched by OCI Client. More... | |
unsigned int | GetPrefetchMemory () const |
Return the amount of memory used to retrieve rows pre-fetched by OCI Client. More... | |
void | SetLongMaxSize (unsigned int value) |
Set the LONG data type piece buffer size. More... | |
unsigned int | GetLongMaxSize () const |
Return the LONG data type piece buffer size. More... | |
void | SetLongMode (LongMode value) |
Set the long data type handling mode of a SQL statement. More... | |
LongMode | GetLongMode () const |
Return the long data type handling mode of a SQL statement. | |
unsigned int | GetSQLCommand () const |
Return the Oracle SQL code the command held by the statement. More... | |
ostring | GetSQLVerb () const |
Return the verb of the SQL command held by the statement. More... | |
void | GetBatchErrors (std::vector< Exception > &exceptions) |
Returns all errors that occurred within a DML array statement execution. | |
Object used for executing SQL or PL/SQL statement and returning the produced results.
This class wraps the OCILIB object handle OCI_Statement and its related methods
Definition at line 5180 of file ocilib.hpp.
Statement Type.
Possible values are Statement::StatementTypeValues
Definition at line 5227 of file ocilib.hpp.
Fetch Modes.
Possible values are Statement::FetchModeValues
Definition at line 5249 of file ocilib.hpp.
Bind Modes.
Possible values are Statement::BindModeValues
Definition at line 5271 of file ocilib.hpp.
LONG data type mapping modes.
Possible values are Statement::LongModeValues
Definition at line 5293 of file ocilib.hpp.
Statement Type enumerated values.
Definition at line 5196 of file ocilib.hpp.
Fetch Modes enumerated values.
Enumerator | |
---|---|
FetchForward |
Statement is forward only |
FetchScrollable |
Statement is scrollable |
Definition at line 5234 of file ocilib.hpp.
Bind Modes enumerated values.
Enumerator | |
---|---|
BindByPosition |
Bind variables are binded by name |
BindByName |
Bind variables are binded by position |
Definition at line 5256 of file ocilib.hpp.
LONG data type mapping modes enumerated values.
Enumerator | |
---|---|
LongExplicit |
LONG and LONG RAW are mapped to Long objects |
LongImplicit |
LONG and LONG RAW are mapped to ostring objects |
Definition at line 5278 of file ocilib.hpp.
|
inline |
Parametrized constructor.
connection | - Parent connection |
Definition at line 4395 of file ocilib_impl.hpp.
References ocilib::Check(), OCI_StatementCreate(), and OCI_StatementFree().
|
inline |
Describe the select list of a SQL select statement.
sql | - SELECT sql statement |
Definition at line 4420 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_Describe().
|
inline |
Parse a SQL statement or PL/SQL block.
sql | - SQL order - PL/SQL block |
Definition at line 4427 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_Parse().
|
inline |
Prepare a SQL statement or PL/SQL block.
sql | - SQL order or PL/SQL block |
Definition at line 4434 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_Prepare().
|
inline |
Prepare and execute a SQL statement or PL/SQL block.
sql | - SQL order - PL/SQL block |
Definition at line 4466 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_ExecuteStmt().
Referenced by ocilib::Subscription::Watch().
|
inline |
Execute the prepared statement, retrieve all resultsets, and call the given callback for each row of each resultsets.
TFetchCallback | - type of the fetch callback |
callback | - User defined callback |
Definition at line 4451 of file ocilib_impl.hpp.
|
inline |
Execute the prepared statement, retrieve all resultsets, and call the given callback with adapted type wit for each row of each resultsets.
TAdapter | - type of the adapter callback |
TFetchCallback | - type of the fetch callback |
callback | - User defined callback |
adapter | - User defined adapter function |
Definition at line 4459 of file ocilib_impl.hpp.
|
inline |
Execute the given SQL statement, retrieve all resultsets, and call the given callback for each row of each resultsets.
TFetchCallback | - type of the fetch callback |
sql | - SQL order - PL/SQL block |
callback | - User defined callback |
Definition at line 4474 of file ocilib_impl.hpp.
|
inline |
Execute the given SQL statement, retrieve all resultsets, and call the given callback with adapted type wit for each row of each resultsets.
TAdapter | - type of the adapter callback |
TFetchCallback | - type of the fetch callback |
sql | - SQL order - PL/SQL block |
callback | - User defined callback |
adapter | - User defined adapter function |
Definition at line 4482 of file ocilib_impl.hpp.
|
inline |
Return the number of rows affected by the SQL statement.
The returned value is :
Definition at line 4521 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetAffectedRows().
|
inline |
Retrieve the resultset from an executed statement.
Definition at line 4531 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetResultset().
|
inline |
Retrieve the next available resultset.
Definition at line 4536 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetNextResultset().
|
inline |
Set the input array size for bulk operations.
size | - Array size |
Definition at line 4541 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_BindArraySetSize().
|
inline |
Allow different host variables to be binded using the same bind name or position between executions of a prepared statement.
value | - Rebinding mode allowed |
Definition at line 4551 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_AllowRebinding().
|
inline |
Indicate if rebinding is allowed on the statement.
Definition at line 4556 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_IsRebindingAllowed().
|
inline |
Return the index of the bind from its name belonging to the statement.
name | - Bind variable name |
Definition at line 4561 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetBindIndex().
|
inline |
Return the bind at the given index in the internal array of bind objects.
index | - Bind position |
Definition at line 4571 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetBind().
Return a bind handle from its name.
name | - Bind variable name |
Definition at line 4576 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetBind2().
void ocilib::Statement::Bind | ( | const ostring & | name, |
TDataType & | value, | ||
BindInfo::BindDirection | mode | ||
) |
Bind an host variable.
TDataType | - C++ type of the host variable |
name | - Bind name |
value | - Host variable |
mode | - bind direction mode |
void ocilib::Statement::Bind | ( | const ostring & | name, |
TDataType & | value, | ||
TExtraInfo | extraInfo, | ||
BindInfo::BindDirection | mode | ||
) |
Bind an host variable with more information.
TDataType | - C++ type of the host variable |
TExtraInfo | - C++ type if the extra information needed for the bind call |
name | - Bind name |
value | - Host variable |
extraInfo | - Extra information needed for the bind call |
mode | - bind direction mode |
|
inline |
Bind a host collection variable.
TDataType | - C++ type of the host collection variable |
name | - Bind name |
value | - Host Collection variable |
mode | - bind direction mode |
Definition at line 4902 of file ocilib_impl.hpp.
References OCI_BindColl().
void ocilib::Statement::Bind | ( | const ostring & | name, |
std::vector< TDataType > & | values, | ||
BindInfo::BindDirection | mode | ||
) |
Bind a vector of host variables.
TDataType | - C++ type of the host variable |
name | - Bind name |
values | - Vector of host variables |
mode | - bind direction mode |
void ocilib::Statement::Bind | ( | const ostring & | name, |
std::vector< TDataType > & | values, | ||
TypeInfo & | typeInfo, | ||
BindInfo::BindDirection | mode | ||
) |
Bind a vector of host variables with Oracle type information.
TDataType | - C++ type of the host variable |
name | - Bind name |
values | - Vector of host variables |
typeInfo | - Object type information |
mode | - bind direction mode |
Definition at line 5024 of file ocilib_impl.hpp.
References OCI_BindArrayOfColls().
|
inline |
Bind a vector of host collection variables with Oracle type information.
TDataType | - collection C++ type of the host collection variables |
name | - Bind name |
values | - Vector of host collection variables |
typeInfo | - Object type information |
mode | - bind direction mode |
Definition at line 4968 of file ocilib_impl.hpp.
References OCI_BindArrayOfColls().
void ocilib::Statement::Bind | ( | const ostring & | name, |
std::vector< TDataType > & | values, | ||
TExtraInfo | extraInfo, | ||
BindInfo::BindDirection | mode | ||
) |
Bind a vector of host variables with more information.
TDataType | - C++ type of the host variable |
TExtraInfo | - C++ type if the extra information needed for the bind call |
name | - Bind name |
values | - Vector of host variables |
extraInfo | - Extra information needed for the bind call |
mode | - bind direction mode |
void ocilib::Statement::Register | ( | const ostring & | name | ) |
Register a host variable as an output for a column present in a SQL RETURNING INTO clause.
TDataType | - C++ type of the host variable |
name | - Bind name |
void ocilib::Statement::Register | ( | const ostring & | name, |
TExtraInfo & | extraInfo | ||
) |
Register a host variable with Oracle type information as an output for a column present in a SQL RETURNING INTO clause.
TDataType | - C++ type of the host variable |
TExtraInfo | - C++ type if the extra information needed for the bind call |
name | - Bind name |
extraInfo | - Extra information needed for the bind call |
void ocilib::Statement::Register | ( | const ostring & | name, |
TExtraInfo | extraInfo | ||
) |
Register a host variable with more information as an output for a column present in a SQL RETURNING INTO clause.
TDataType | - C++ type of the host variable |
TExtraInfo | - C++ type if the extra information needed for the bind call |
name | - Bind name |
extraInfo | - Extra information needed for the bind call |
|
inline |
Return the error position (in terms of characters) in the SQL statement where the error occurred in case of SQL parsing error.
Definition at line 5173 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetSqlErrorPos().
|
inline |
Set the fetch mode of a SQL statement.
value | - fetch mode value |
Definition at line 5178 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetFetchMode().
|
inline |
Return the fetch mode of a SQL statement.
Definition at line 5183 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetFetchMode().
|
inline |
Set the binding mode of a SQL statement.
value | - binding mode value |
Definition at line 5188 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetBindMode().
|
inline |
Return the binding mode of a SQL statement.
Definition at line 5193 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetBindMode().
|
inline |
Set the number of rows fetched per internal server fetch call.
value | - number of rows to fetch |
Definition at line 5198 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetFetchSize().
|
inline |
Return the number of rows fetched per internal server fetch call.
Definition at line 5203 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetFetchSize().
|
inline |
Set the number of rows pre-fetched by OCI Client.
value | - number of rows to pre-fetch |
Definition at line 5208 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetPrefetchSize().
|
inline |
Return the number of rows pre-fetched by OCI Client.
Definition at line 5213 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetPrefetchSize().
|
inline |
Set the amount of memory pre-fetched by OCI Client.
value | - amount of memory to fetch |
Definition at line 5218 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetPrefetchMemory().
|
inline |
Return the amount of memory used to retrieve rows pre-fetched by OCI Client.
Definition at line 5223 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetPrefetchMemory().
|
inline |
Set the LONG data type piece buffer size.
value | - maximum size for long buffer |
Definition at line 5228 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetLongMaxSize().
|
inline |
Return the LONG data type piece buffer size.
Definition at line 5233 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetLongMaxSize().
|
inline |
Set the long data type handling mode of a SQL statement.
value | - long mode value |
Definition at line 5238 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetLongMode().
|
inline |
Return the Oracle SQL code the command held by the statement.
Definition at line 5248 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetSQLCommand().
|
inline |
Return the verb of the SQL command held by the statement.
Definition at line 5253 of file ocilib_impl.hpp.
References ocilib::Check(), ocilib::MakeString(), and OCI_GetSQLVerb().