OCILIB (C and C++ Driver for Oracle)
4.7.5
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
|
Object used for executing SQL or PL/SQL statement and returning the produced results. More...
#include <types.hpp>
Inherits ocilib::core::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 , TypeMerge = OCI_CST_MERGE } |
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 core::Enum< StatementTypeValues > | StatementType |
Statement Type. | |
typedef core::Enum< FetchModeValues > | FetchMode |
Fetch Modes. | |
typedef core::Enum< BindModeValues > | BindMode |
Bind Modes. | |
typedef core::Enum< LongModeValues > | LongMode |
LONG data type mapping modes. | |
Public Member Functions | |
Statement () | |
Create an empty null Statement instance. | |
Statement (const Connection &connection) | |
Parametrized constructor. | |
Connection | GetConnection () const |
Return the connection associated with a statement. | |
void | Describe (const ostring &sql) |
Describe the select list of a SQL select statement. | |
void | Parse (const ostring &sql) |
Parse a SQL statement or PL/SQL block. | |
void | Prepare (const ostring &sql) |
Prepare a SQL statement or PL/SQL block. | |
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. | |
template<class T > | |
unsigned int | ExecutePrepared (T callback) |
Execute the prepared statement, retrieve all resultsets, and call the given callback for each row of each resultsets. | |
template<class T , class U > | |
unsigned int | ExecutePrepared (T callback, U adapter) |
Execute the prepared statement, retrieve all resultsets, and call the given callback with adapted type wit for each row of each resultsets. | |
template<class T > | |
unsigned int | Execute (const ostring &sql, T callback) |
Execute the given SQL statement, retrieve all resultsets, and call the given callback for each row of each resultsets. | |
template<class T , class U > | |
unsigned int | Execute (const ostring &sql, T callback, U adapter) |
Execute the given SQL statement, retrieve all resultsets, and call the given callback with adapted type wit for each row of each resultsets. | |
unsigned int | GetAffectedRows () const |
Return the number of rows affected by the SQL statement. | |
ostring | GetSql () const |
Return the last SQL or PL/SQL statement prepared or executed by the statement. | |
ostring | GetSqlIdentifier () const |
Return the server SQL_ID of the last SQL or PL/SQL statement prepared or executed by the statement. | |
Resultset | GetResultset () |
Retrieve the resultset from an executed statement. | |
Resultset | GetNextResultset () |
Retrieve the next available resultset. | |
void | SetBindArraySize (unsigned int size) |
Set the input array size for bulk operations. | |
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. | |
bool | IsRebindingAllowed () const |
Indicate if rebinding is allowed on the statement. | |
unsigned int | GetBindIndex (const ostring &name) const |
Return the index of the bind from its name belonging to the statement. | |
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. | |
BindInfo | GetBind (const ostring &name) const |
Return a bind handle from its name. | |
template<class T > | |
void | Bind (const ostring &name, T &value, BindInfo::BindDirection mode) |
Bind an host variable. | |
template<class T , class U > | |
void | Bind (const ostring &name, T &value, U extraInfo, BindInfo::BindDirection mode) |
Bind an host variable with more information. | |
template<class T > | |
void | Bind (const ostring &name, Collection< T > &value, BindInfo::BindDirection mode) |
Bind a host collection variable. | |
template<class T > | |
void | Bind (const ostring &name, std::vector< T > &values, BindInfo::BindDirection mode, BindInfo::VectorType type=BindInfo::AsArray) |
Bind a vector of host variables. | |
template<class T > | |
void | Bind (const ostring &name, std::vector< T > &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type=BindInfo::AsArray) |
Bind a vector of host variables with Oracle type information. | |
template<class T > | |
void | Bind (const ostring &name, std::vector< Collection< T > > &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type=BindInfo::AsArray) |
Bind a vector of host collection variables with Oracle type information. | |
template<class T , class U > | |
void | Bind (const ostring &name, std::vector< T > &values, U extraInfo, BindInfo::BindDirection mode, BindInfo::VectorType type=BindInfo::AsArray) |
Bind a vector of host variables with more information. | |
template<class T > | |
void | Register (const ostring &name) |
Register a host variable as an output for a column present in a SQL RETURNING INTO clause. | |
template<class T , class U > | |
void | Register (const ostring &name, U &extraInfo) |
Register a host variable with Oracle type information as an output for a column present in a SQL RETURNING INTO clause. | |
template<class T , class U > | |
void | Register (const ostring &name, U extraInfo) |
Register a host variable with more information as an output for a column present in a SQL RETURNING INTO clause. | |
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. | |
void | SetFetchMode (FetchMode value) |
Set the fetch mode of a SQL statement. | |
FetchMode | GetFetchMode () const |
Return the fetch mode of a SQL statement. | |
void | SetBindMode (BindMode value) |
Set the binding mode of a SQL statement. | |
BindMode | GetBindMode () const |
Return the binding mode of a SQL statement. | |
void | SetFetchSize (unsigned int value) |
Set the number of rows fetched per internal server fetch call. | |
unsigned int | GetFetchSize () const |
Return the number of rows fetched per internal server fetch call. | |
void | SetPrefetchSize (unsigned int value) |
Set the number of rows pre-fetched by OCI Client. | |
unsigned int | GetPrefetchSize () const |
Return the number of rows pre-fetched by OCI Client. | |
void | SetPrefetchMemory (unsigned int value) |
Set the amount of memory pre-fetched by OCI Client. | |
unsigned int | GetPrefetchMemory () const |
Return the amount of memory used to retrieve rows pre-fetched by OCI Client. | |
void | SetLongMaxSize (unsigned int value) |
Set the LONG data type piece buffer size. | |
unsigned int | GetLongMaxSize () const |
Return the LONG data type piece buffer size. | |
void | SetLongMode (LongMode value) |
Set the long data type handling mode of a SQL statement. | |
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. | |
ostring | GetSQLVerb () const |
Return the verb of the SQL command held by the statement. | |
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
Statement Type.
Possible values are Statement::StatementTypeValues
Fetch Modes.
Possible values are Statement::FetchModeValues
Bind Modes.
Possible values are Statement::BindModeValues
LONG data type mapping modes.
Possible values are Statement::LongModeValues
Statement Type enumerated values.
|
inline |
Create an empty null Statement instance.
Definition at line 46 of file Statement.hpp.
|
inline |
Parametrized constructor.
connection | - Parent connection |
Definition at line 50 of file Statement.hpp.
References ocilib::core::Check(), and OCI_StatementCreate().
|
inline |
Return the connection associated with a statement.
Definition at line 65 of file Statement.hpp.
References ocilib::core::Check(), and OCI_StatementGetConnection().
|
inline |
Describe the select list of a SQL select statement.
sql | - SELECT sql statement |
Definition at line 70 of file Statement.hpp.
References ocilib::core::Check(), and OCI_Describe().
|
inline |
Parse a SQL statement or PL/SQL block.
sql | - SQL order - PL/SQL block |
Definition at line 77 of file Statement.hpp.
References ocilib::core::Check(), and OCI_Parse().
|
inline |
Prepare a SQL statement or PL/SQL block.
sql | - SQL order or PL/SQL block |
Definition at line 84 of file Statement.hpp.
References ocilib::core::Check(), and OCI_Prepare().
|
inline |
Execute a prepared SQL statement or PL/SQL block.
Definition at line 91 of file Statement.hpp.
References ocilib::core::Check(), and OCI_Execute().
Referenced by ExecutePrepared().
|
inline |
Prepare and execute a SQL statement or PL/SQL block.
sql | - SQL order - PL/SQL block |
Definition at line 115 of file Statement.hpp.
References ocilib::core::Check(), and OCI_ExecuteStmt().
Referenced by Execute(), and ocilib::Subscription::Watch().
unsigned int ocilib::Statement::ExecutePrepared | ( | T | callback | ) |
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 100 of file Statement.hpp.
References ExecutePrepared().
unsigned int ocilib::Statement::ExecutePrepared | ( | T | callback, |
U | adapter | ||
) |
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 108 of file Statement.hpp.
References ExecutePrepared().
unsigned int ocilib::Statement::Execute | ( | const ostring & | sql, |
T | callback | ||
) |
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 123 of file Statement.hpp.
References Execute().
unsigned int ocilib::Statement::Execute | ( | const ostring & | sql, |
T | callback, | ||
U | adapter | ||
) |
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 131 of file Statement.hpp.
References Execute().
|
inline |
Return the number of rows affected by the SQL statement.
The returned value is :
Definition at line 170 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetAffectedRows().
|
inline |
Return the last SQL or PL/SQL statement prepared or executed by the statement.
Definition at line 175 of file Statement.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetSql().
|
inline |
Return the server SQL_ID of the last SQL or PL/SQL statement prepared or executed by the statement.
Definition at line 180 of file Statement.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetSqlIdentifier().
|
inline |
Retrieve the resultset from an executed statement.
Definition at line 185 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetResultset().
|
inline |
Retrieve the next available resultset.
Definition at line 190 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetNextResultset().
|
inline |
Set the input array size for bulk operations.
size | - Array size |
Definition at line 195 of file Statement.hpp.
References ocilib::core::Check(), and OCI_BindArraySetSize().
|
inline |
Return the current input array size for bulk operations.
Definition at line 200 of file Statement.hpp.
References ocilib::core::Check(), and OCI_BindArrayGetSize().
|
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 205 of file Statement.hpp.
References ocilib::core::Check(), and OCI_AllowRebinding().
|
inline |
Indicate if rebinding is allowed on the statement.
Definition at line 210 of file Statement.hpp.
References ocilib::core::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 215 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetBindIndex().
|
inline |
Return the number of binds currently associated to a statement.
Definition at line 220 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetBindCount().
|
inline |
Return the bind at the given index in the internal array of bind objects.
index | - Bind position |
Definition at line 225 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetBind().
Return a bind handle from its name.
name | - Bind variable name |
Definition at line 230 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetBind2().
void ocilib::Statement::Bind | ( | const ostring & | name, |
T & | value, | ||
BindInfo::BindDirection | mode | ||
) |
Bind an host variable.
T | - C++ type of the host variable |
name | - Bind name |
value | - Host variable |
mode | - bind direction mode |
void ocilib::Statement::Bind | ( | const ostring & | name, |
T & | value, | ||
U | extraInfo, | ||
BindInfo::BindDirection | mode | ||
) |
Bind an host variable with more information.
T | - 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 |
void ocilib::Statement::Bind | ( | const ostring & | name, |
Collection< T > & | value, | ||
BindInfo::BindDirection | mode | ||
) |
Bind a host collection variable.
T | - C++ type of the host collection variable |
name | - Bind name |
value | - Host Collection variable |
mode | - bind direction mode |
Definition at line 583 of file Statement.hpp.
References ocilib::core::Check(), and OCI_BindColl().
void ocilib::Statement::Bind | ( | const ostring & | name, |
std::vector< T > & | values, | ||
BindInfo::BindDirection | mode, | ||
BindInfo::VectorType | type = BindInfo::AsArray |
||
) |
Bind a vector of host variables.
T | - C++ type of the host variable |
name | - Bind name |
values | - Vector of host variables |
mode | - bind direction mode |
type | - vector type (regular array or PL/SQL table) |
void ocilib::Statement::Bind | ( | const ostring & | name, |
std::vector< T > & | values, | ||
TypeInfo & | typeInfo, | ||
BindInfo::BindDirection | mode, | ||
BindInfo::VectorType | type = BindInfo::AsArray |
||
) |
Bind a vector of host variables with Oracle type information.
T | - C++ type of the host variable |
name | - Bind name |
values | - Vector of host variables |
typeInfo | - Object type information |
mode | - bind direction mode |
type | - vector type (regular array or PL/SQL table) |
Definition at line 706 of file Statement.hpp.
References OCI_BindArrayOfColls().
void ocilib::Statement::Bind | ( | const ostring & | name, |
std::vector< Collection< T > > & | values, | ||
TypeInfo & | typeInfo, | ||
BindInfo::BindDirection | mode, | ||
BindInfo::VectorType | type = BindInfo::AsArray |
||
) |
Bind a vector of host collection variables with Oracle type information.
T | - 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 |
type | - vector type (regular array or PL/SQL table) |
Definition at line 650 of file Statement.hpp.
References OCI_BindArrayOfColls().
void ocilib::Statement::Bind | ( | const ostring & | name, |
std::vector< T > & | values, | ||
U | extraInfo, | ||
BindInfo::BindDirection | mode, | ||
BindInfo::VectorType | type = BindInfo::AsArray |
||
) |
Bind a vector of host variables with more information.
T | - 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 |
type | - vector type (regular array or PL/SQL table) |
void ocilib::Statement::Register | ( | const ostring & | name | ) |
Register a host variable as an output for a column present in a SQL RETURNING INTO clause.
T | - C++ type of the host variable |
name | - Bind name |
void ocilib::Statement::Register | ( | const ostring & | name, |
U & | extraInfo | ||
) |
Register a host variable with Oracle type information as an output for a column present in a SQL RETURNING INTO clause.
T | - 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, |
U | extraInfo | ||
) |
Register a host variable with more information as an output for a column present in a SQL RETURNING INTO clause.
T | - 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 type of a SQL statement.
Definition at line 855 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetStatementType().
|
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 860 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetSqlErrorPos().
|
inline |
Set the fetch mode of a SQL statement.
value | - fetch mode value |
Definition at line 865 of file Statement.hpp.
References ocilib::core::Check(), and OCI_SetFetchMode().
|
inline |
Return the fetch mode of a SQL statement.
Definition at line 870 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetFetchMode().
|
inline |
Set the binding mode of a SQL statement.
value | - binding mode value |
Definition at line 875 of file Statement.hpp.
References ocilib::core::Check(), and OCI_SetBindMode().
|
inline |
Return the binding mode of a SQL statement.
Definition at line 880 of file Statement.hpp.
References ocilib::core::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 885 of file Statement.hpp.
References ocilib::core::Check(), and OCI_SetFetchSize().
|
inline |
Return the number of rows fetched per internal server fetch call.
Definition at line 890 of file Statement.hpp.
References ocilib::core::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 895 of file Statement.hpp.
References ocilib::core::Check(), and OCI_SetPrefetchSize().
|
inline |
Return the number of rows pre-fetched by OCI Client.
Definition at line 900 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetPrefetchSize().
|
inline |
Set the amount of memory pre-fetched by OCI Client.
value | - amount of memory to fetch |
Definition at line 905 of file Statement.hpp.
References ocilib::core::Check(), and OCI_SetPrefetchMemory().
|
inline |
Return the amount of memory used to retrieve rows pre-fetched by OCI Client.
Definition at line 910 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetPrefetchMemory().
|
inline |
Set the LONG data type piece buffer size.
value | - maximum size for long buffer |
Definition at line 915 of file Statement.hpp.
References ocilib::core::Check(), and OCI_SetLongMaxSize().
|
inline |
Return the LONG data type piece buffer size.
Definition at line 920 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetLongMaxSize().
|
inline |
Set the long data type handling mode of a SQL statement.
value | - long mode value |
Definition at line 925 of file Statement.hpp.
References ocilib::core::Check(), and OCI_SetLongMode().
|
inline |
Return the long data type handling mode of a SQL statement.
Definition at line 930 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetLongMode().
|
inline |
Return the Oracle SQL code the command held by the statement.
Definition at line 935 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetSQLCommand().
|
inline |
Return the verb of the SQL command held by the statement.
Definition at line 940 of file Statement.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetSQLVerb().
|
inline |
Returns all errors that occurred within a DML array statement execution.
Definition at line 945 of file Statement.hpp.
References ocilib::core::Check(), and OCI_GetBatchError().