|
OCILIB (C and C++ Driver for Oracle)
4.6.3
|
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, 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 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... | |
| 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 T > | |
| unsigned int | ExecutePrepared (T callback) |
| Execute the prepared statement, retrieve all resultsets, and call the given callback for each row of each resultsets. More... | |
| 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. More... | |
| 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. More... | |
| 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. 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. | |
| 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. 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 T > | |
| void | Bind (const ostring &name, T &value, BindInfo::BindDirection mode) |
| Bind an host variable. More... | |
| template<class T , class U > | |
| void | Bind (const ostring &name, T &value, U extraInfo, BindInfo::BindDirection mode) |
| Bind an host variable with more information. More... | |
| template<class T > | |
| void | Bind (const ostring &name, Collection< T > &value, BindInfo::BindDirection mode) |
| Bind a host collection variable. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. 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 5689 of file ocilib.hpp.
Statement Type.
Possible values are Statement::StatementTypeValues
Definition at line 5738 of file ocilib.hpp.
Fetch Modes.
Possible values are Statement::FetchModeValues
Definition at line 5760 of file ocilib.hpp.
Bind Modes.
Possible values are Statement::BindModeValues
Definition at line 5782 of file ocilib.hpp.
LONG data type mapping modes.
Possible values are Statement::LongModeValues
Definition at line 5804 of file ocilib.hpp.
Statement Type enumerated values.
Definition at line 5705 of file ocilib.hpp.
Fetch Modes enumerated values.
| Enumerator | |
|---|---|
| FetchForward | Statement is forward only |
| FetchScrollable | Statement is scrollable |
Definition at line 5745 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 5767 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 5789 of file ocilib.hpp.
|
inline |
Parametrized constructor.
| connection | - Parent connection |
Definition at line 5105 of file ocilib_impl.hpp.
References ocilib::Check(), OCI_StatementCreate(), OCI_StatementFree(), and Statement().
|
inline |
Describe the select list of a SQL select statement.
| sql | - SELECT sql statement |
Definition at line 5120 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 5127 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 5134 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 5165 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_ExecuteStmt().
Referenced by 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 5150 of file ocilib_impl.hpp.
| 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 5158 of file ocilib_impl.hpp.
| 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 5173 of file ocilib_impl.hpp.
| 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 5181 of file ocilib_impl.hpp.
References ocilib::Resultset::ForEach().
|
inline |
Return the number of rows affected by the SQL statement.
The returned value is :
Definition at line 5220 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetAffectedRows().
|
inline |
Retrieve the resultset from an executed statement.
Definition at line 5235 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_GetResultset().
|
inline |
Retrieve the next available resultset.
Definition at line 5240 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 5245 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 5255 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_AllowRebinding().
|
inline |
Indicate if rebinding is allowed on the statement.
Definition at line 5260 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 5265 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 5275 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 5280 of file ocilib_impl.hpp.
References ocilib::BindInfo::AsPlSqlTable, ocilib::Check(), OCI_BindArrayOfBigInts(), OCI_BindArrayOfDates(), OCI_BindArrayOfDoubles(), OCI_BindArrayOfFloats(), OCI_BindArrayOfInts(), OCI_BindArrayOfNumbers(), OCI_BindArrayOfShorts(), OCI_BindArrayOfUnsignedBigInts(), OCI_BindArrayOfUnsignedInts(), OCI_BindArrayOfUnsignedShorts(), OCI_BindBigInt(), OCI_BindBoolean(), OCI_BindDate(), OCI_BindDouble(), OCI_BindFile(), OCI_BindFloat(), OCI_BindInt(), OCI_BindInterval(), OCI_BindLob(), OCI_BindLong(), OCI_BindNumber(), OCI_BindObject(), OCI_BindRaw(), OCI_BindRef(), OCI_BindShort(), OCI_BindStatement(), OCI_BindString(), OCI_BindTimestamp(), OCI_BindUnsignedBigInt(), OCI_BindUnsignedInt(), OCI_BindUnsignedShort(), 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 5633 of file ocilib_impl.hpp.
References ocilib::Check(), OCI_BindArrayOfFiles(), OCI_BindArrayOfIntervals(), OCI_BindArrayOfLobs(), OCI_BindArrayOfObjects(), OCI_BindArrayOfRefs(), OCI_BindArrayOfTimestamps(), 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 5756 of file ocilib_impl.hpp.
References ocilib::Check(), OCI_BindArrayOfColls(), OCI_RegisterBigInt(), OCI_RegisterDate(), OCI_RegisterDouble(), OCI_RegisterFile(), OCI_RegisterFloat(), OCI_RegisterInt(), OCI_RegisterInterval(), OCI_RegisterLob(), OCI_RegisterNumber(), OCI_RegisterObject(), OCI_RegisterRaw(), OCI_RegisterRef(), OCI_RegisterShort(), OCI_RegisterString(), OCI_RegisterTimestamp(), OCI_RegisterUnsignedBigInt(), OCI_RegisterUnsignedInt(), and OCI_RegisterUnsignedShort().
| 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 5700 of file ocilib_impl.hpp.
References ocilib::BindInfo::AsPlSqlTable, ocilib::Check(), OCI_BindArrayOfColls(), OCI_BindArrayOfRaws(), and OCI_BindArrayOfStrings().
| 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 error position (in terms of characters) in the SQL statement where the error occurred in case of SQL parsing error.
Definition at line 5910 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 5915 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetFetchMode().
|
inline |
Return the fetch mode of a SQL statement.
Definition at line 5920 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 5925 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetBindMode().
|
inline |
Return the binding mode of a SQL statement.
Definition at line 5930 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 5935 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 5940 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 5945 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 5950 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 5955 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 5960 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 5965 of file ocilib_impl.hpp.
References ocilib::Check(), and OCI_SetLongMaxSize().
|
inline |
Return the LONG data type piece buffer size.
Definition at line 5970 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 5975 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 5985 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 5990 of file ocilib_impl.hpp.
References ocilib::Check(), ocilib::MakeString(), and OCI_GetSQLVerb().