OCILIB (C and C++ Driver for Oracle)  4.7.5
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Loading...
Searching...
No Matches
ocilib::Statement Class Reference

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< StatementTypeValuesStatementType
 Statement Type.
 
typedef core::Enum< FetchModeValuesFetchMode
 Fetch Modes.
 
typedef core::Enum< BindModeValuesBindMode
 Bind Modes.
 
typedef core::Enum< LongModeValuesLongMode
 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.
 

Detailed Description

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 5555 of file types.hpp.

Member Typedef Documentation

◆ StatementType

◆ FetchMode

Fetch Modes.

Possible values are Statement::FetchModeValues

Definition at line 5626 of file types.hpp.

◆ BindMode

Bind Modes.

Possible values are Statement::BindModeValues

Definition at line 5648 of file types.hpp.

◆ LongMode

LONG data type mapping modes.

Possible values are Statement::LongModeValues

Definition at line 5670 of file types.hpp.

Member Enumeration Documentation

◆ StatementTypeValues

Statement Type enumerated values.

Enumerator
TypeSelect 

SELECT statement

TypeUpdate 

UPDATE statement

TypeDelete 

DELETE statement

TypeInsert 

INSERT statement

TypeCreate 

CREATE statement

TypeDrop 

DROP statement

TypeAlter 

ALTER statement

TypeBegin 

BEGIN statement

TypeDeclare 

DECLARE statement

TypeCall 

CALL statement

TypeMerge 

MERGE statement

Definition at line 5571 of file types.hpp.

◆ FetchModeValues

Fetch Modes enumerated values.

Enumerator
FetchForward 

Statement is forward only

FetchScrollable 

Statement is scrollable

Definition at line 5611 of file types.hpp.

◆ BindModeValues

Bind Modes enumerated values.

Enumerator
BindByPosition 

Bind variables are binded by name

BindByName 

Bind variables are binded by position

Definition at line 5633 of file types.hpp.

◆ LongModeValues

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 5655 of file types.hpp.

Constructor & Destructor Documentation

◆ Statement() [1/2]

ocilib::Statement::Statement ( )
inline

Create an empty null Statement instance.

Definition at line 46 of file Statement.hpp.

◆ Statement() [2/2]

ocilib::Statement::Statement ( const Connection connection)
inline

Parametrized constructor.

Parameters
connection- Parent connection
Note
  • The statement object must not be accessed anymore once the parent connection object gets out of scope

Definition at line 50 of file Statement.hpp.

References ocilib::core::Check(), and OCI_StatementCreate().

Member Function Documentation

◆ GetConnection()

Connection ocilib::Statement::GetConnection ( ) const
inline

Return the connection associated with a statement.

Definition at line 65 of file Statement.hpp.

References ocilib::core::Check(), and OCI_StatementGetConnection().

◆ Describe()

void ocilib::Statement::Describe ( const ostring sql)
inline

Describe the select list of a SQL select statement.

Parameters
sql- SELECT sql statement
Note
This call sends the SELECT SQL order to the server for retrieving the description of the select order only. The command is not executed. This call is only useful to retrieve information on the associated resultset Call GetResultset() after Describe() to access to SELECT list information
This call prepares the statement (internal call to Prepare()) and ask the Oracle server to describe the output SELECT list. Execute() can be called after Describe() in order to execute the statement, which means that the server will parse, and describe again the SQL order.
Warning
Do not use Describe() unless you're only interested in the resultset information because the statement will be parsed again when executed and thus leading to unnecessary server round trips and less performance

Definition at line 70 of file Statement.hpp.

References ocilib::core::Check(), and OCI_Describe().

◆ Parse()

void ocilib::Statement::Parse ( const ostring sql)
inline

Parse a SQL statement or PL/SQL block.

Parameters
sql- SQL order - PL/SQL block
Note
This call sends the SQL or PL/SQL command to the server for parsing only. The command is not executed. This call is only useful to check is a command is valid or not.
This call prepares the statement (internal call to Prepare()) and ask the Oracle server to parse its SQL or PL/SQL command. Execute() can be call after Parse() in order to execute the statement, which means that the server will parse again the command.
Warning
Do not use Parse() unless you're only interested in the parsing result because the statement will be parsed again when executed and thus leading to unnecessary server round trips and less performance

Definition at line 77 of file Statement.hpp.

References ocilib::core::Check(), and OCI_Parse().

◆ Prepare()

void ocilib::Statement::Prepare ( const ostring sql)
inline

Prepare a SQL statement or PL/SQL block.

Parameters
sql- SQL order or PL/SQL block
Note
With version 1.3.0 and above, do not call this function for fetched statements (REF cursors)

Definition at line 84 of file Statement.hpp.

References ocilib::core::Check(), and OCI_Prepare().

◆ ExecutePrepared() [1/3]

void ocilib::Statement::ExecutePrepared ( )
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().

◆ Execute() [1/3]

void ocilib::Statement::Execute ( const ostring sql)
inline

Prepare and execute a SQL statement or PL/SQL block.

Parameters
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().

◆ ExecutePrepared() [2/3]

template<class T >
unsigned int ocilib::Statement::ExecutePrepared ( callback)

Execute the prepared statement, retrieve all resultsets, and call the given callback for each row of each resultsets.

Template Parameters
TFetchCallback- type of the fetch callback
Parameters
callback- User defined callback
Note
The user defined callback function must conform to the following prototype: bool callback(const Resultset &) It shall return true to continue fetching the resultset or false to stop the fetch
Returns
The number of rows fetched

Definition at line 100 of file Statement.hpp.

References ExecutePrepared().

◆ ExecutePrepared() [3/3]

template<class T , class U >
unsigned int ocilib::Statement::ExecutePrepared ( callback,
adapter 
)

Execute the prepared statement, retrieve all resultsets, and call the given callback with adapted type wit for each row of each resultsets.

Template Parameters
TAdapter- type of the adapter callback
TFetchCallback- type of the fetch callback
Parameters
callback- User defined callback
adapter- User defined adapter function
Note
The user defined callback function must conform to the following prototype: bool callback(const Resultset &) It shall return true to continue fetching the resultset or false to stop the fetch
Returns
The number of rows fetched

Definition at line 108 of file Statement.hpp.

References ExecutePrepared().

◆ Execute() [2/3]

template<class T >
unsigned int ocilib::Statement::Execute ( const ostring sql,
callback 
)

Execute the given SQL statement, retrieve all resultsets, and call the given callback for each row of each resultsets.

Template Parameters
TFetchCallback- type of the fetch callback
Parameters
sql- SQL order - PL/SQL block
callback- User defined callback
Note
The user defined callback function must conform to the following prototype: bool callback(const Resultset &) It shall return true to continue fetching the resultset or false to stop the fetch
Returns
The number of rows fetched

Definition at line 123 of file Statement.hpp.

References Execute().

◆ Execute() [3/3]

template<class T , class U >
unsigned int ocilib::Statement::Execute ( const ostring sql,
callback,
adapter 
)

Execute the given SQL statement, retrieve all resultsets, and call the given callback with adapted type wit for each row of each resultsets.

Template Parameters
TAdapter- type of the adapter callback
TFetchCallback- type of the fetch callback
Parameters
sql- SQL order - PL/SQL block
callback- User defined callback
adapter- User defined adapter function
Note
The user defined callback function must conform to the following prototype: bool callback(const Resultset &) It shall return true to continue fetching the resultset or false to stop the fetch
Returns
The number of rows fetched

Definition at line 131 of file Statement.hpp.

References Execute().

◆ GetAffectedRows()

unsigned int ocilib::Statement::GetAffectedRows ( ) const
inline

Return the number of rows affected by the SQL statement.

The returned value is :

  • For UPDATEs : number of rows updated
  • For INSERTs : number of rows inserted
  • For DELETEs : number of rows deleted
Note
For SELECTs statements, use GetRowCount() instead

Definition at line 170 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetAffectedRows().

◆ GetSql()

ostring ocilib::Statement::GetSql ( ) const
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().

◆ GetSqlIdentifier()

ostring ocilib::Statement::GetSqlIdentifier ( ) const
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().

◆ GetResultset()

Resultset ocilib::Statement::GetResultset ( )
inline

Retrieve the resultset from an executed statement.

Note
See Fetching data for more details about what statements can return resultsets
Warning
If the statement has not been prepared and executed, null resultset object will be returned

Definition at line 185 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetResultset().

◆ GetNextResultset()

Resultset ocilib::Statement::GetNextResultset ( )
inline

Retrieve the next available resultset.

Note
it is only valid for the following statements:
  • Statements executing SQL UPDATE/DELETE using a RETURNING INTO clause
  • Statements implicitly returned from PL/SQL procedure or blocks (new feature in Oracle 12cR1) using DBMS_SQL.RETURN_RESULT()
SQL statements with a 'returning' clause can return multiple resultsets. When arrays of program variables are binded to the statement, Oracle will execute the statement for every row (iteration). Each iteration generates a resultset that can be fetched like regular ones.
Starting withOracle 12cR1, PL/SQ procedure and blocks can return multiple implicit resultsets Refer to Oracle documentation for more information.

Definition at line 190 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetNextResultset().

◆ SetBindArraySize()

void ocilib::Statement::SetBindArraySize ( unsigned int  size)
inline

Set the input array size for bulk operations.

Parameters
size- Array size
Warning
Do not use SetBindArraySize() for PL/SQL tables binding
Note
SetBindArraySize() is used to set the size of input bind array when using arrays for DML statements. SetBindArraySize() MUST be called to set the maximum size of the arrays to bind to the statement before any of its execution. This initial call must be bone AFTER OPrepare() and BEFORE any Bind() call taking vectors as parameter.
SetBindArraySize() can optionally be called before any later Execute() call in order to notify the statement of the exact number of elements populating the input arrays for the next execution. The array size passed to later SetBindArraySize() calls cannot be greater than the initial size otherwise an exception will be thrown.

Definition at line 195 of file Statement.hpp.

References ocilib::core::Check(), and OCI_BindArraySetSize().

◆ GetBindArraySize()

unsigned int ocilib::Statement::GetBindArraySize ( ) const
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().

◆ AllowRebinding()

void ocilib::Statement::AllowRebinding ( bool  value)
inline

Allow different host variables to be binded using the same bind name or position between executions of a prepared statement.

Parameters
value- Rebinding mode allowed
Note
Default value is false
Warning
When using rebinding feature, host variable re-binded to a previously allocated bind MUST be of the same data type !

Definition at line 205 of file Statement.hpp.

References ocilib::core::Check(), and OCI_AllowRebinding().

◆ IsRebindingAllowed()

bool ocilib::Statement::IsRebindingAllowed ( ) const
inline

Indicate if rebinding is allowed on the statement.

Note
See AllowRebinding() for more details

Definition at line 210 of file Statement.hpp.

References ocilib::core::Check(), and OCI_IsRebindingAllowed().

◆ GetBindIndex()

unsigned int ocilib::Statement::GetBindIndex ( const ostring name) const
inline

Return the index of the bind from its name belonging to the statement.

Parameters
name- Bind variable name
Warning
The bind name is case insensitive
Note
Bind indexes start with 1 in OCILIB
Returns
Bind index on success or zero if the bind does not exists

Definition at line 215 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetBindIndex().

◆ GetBindCount()

unsigned int ocilib::Statement::GetBindCount ( ) const
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().

◆ GetBind() [1/2]

BindInfo ocilib::Statement::GetBind ( unsigned int  index) const
inline

Return the bind at the given index in the internal array of bind objects.

Parameters
index- Bind position
Warning
Index starts at 1.
Note
Bind handle are created sequentially. For example, the third call to a Bind() call generates a bind object of index 3.

Definition at line 225 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetBind().

◆ GetBind() [2/2]

BindInfo ocilib::Statement::GetBind ( const ostring name) const
inline

Return a bind handle from its name.

Parameters
name- Bind variable name
Note
Bind names must include a semicolon at the beginning.

Definition at line 230 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetBind2().

◆ Bind() [1/7]

template<class T >
void ocilib::Statement::Bind ( const ostring name,
T &  value,
BindInfo::BindDirection  mode 
)

Bind an host variable.

Template Parameters
T- C++ type of the host variable
Parameters
name- Bind name
value- Host variable
mode- bind direction mode
Warning
This method has built-in specialized versions for all supported types except ostring, Clong and Blong variables. For binding ostring, Clong and Blong variables, use the version with an extra parameter.
Note
It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved automatically from the arguments.

◆ Bind() [2/7]

template<class T , class U >
void ocilib::Statement::Bind ( const ostring name,
T &  value,
extraInfo,
BindInfo::BindDirection  mode 
)

Bind an host variable with more information.

Template Parameters
T- C++ type of the host variable
TExtraInfo- C++ type if the extra information needed for the bind call
Parameters
name- Bind name
value- Host variable
extraInfo- Extra information needed for the bind call
mode- bind direction mode
Warning
This method has built-in specialized versions for ostring, Clong and Blong variables. Pass the maximum length/size of the variable in the parameter extraInfo
Note
It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved automatically from the arguments.

◆ Bind() [3/7]

template<class T >
void ocilib::Statement::Bind ( const ostring name,
Collection< T > &  value,
BindInfo::BindDirection  mode 
)

Bind a host collection variable.

Template Parameters
T- C++ type of the host collection variable
Parameters
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().

◆ Bind() [4/7]

template<class T >
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.

Template Parameters
T- C++ type of the host variable
Parameters
name- Bind name
values- Vector of host variables
mode- bind direction mode
type- vector type (regular array or PL/SQL table)
Warning
This method has built-in specialized versions for all C++ native scalar types, Date time and Statement objects. For others types (ostring, Clong, Blong, Raw, Object, Reference, Collection, Timestamp, Interval), use versions with extra parameters.
Note
It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved automatically from the arguments.

◆ Bind() [5/7]

template<class T >
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.

Template Parameters
T- C++ type of the host variable
Parameters
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)
Warning
This method has built-in specialized versions for Object, Reference.
Note
It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved automatically from the arguments.

Definition at line 706 of file Statement.hpp.

References OCI_BindArrayOfColls().

◆ Bind() [6/7]

template<class T >
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.

Template Parameters
T- collection C++ type of the host collection variables
Parameters
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().

◆ Bind() [7/7]

template<class T , class U >
void ocilib::Statement::Bind ( const ostring name,
std::vector< T > &  values,
extraInfo,
BindInfo::BindDirection  mode,
BindInfo::VectorType  type = BindInfo::AsArray 
)

Bind a vector of host variables with more information.

Template Parameters
T- C++ type of the host variable
TExtraInfo- C++ type if the extra information needed for the bind call
Parameters
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)
Warning
This method has built-in specialized versions for ostring, Raw , Clong, Blong, Timestamp, Interval variables.
  • For ostring, Clong, Blong, Raw : Pass the maximum length/size of variables in the parameter extraInfo
  • For Timestamp, Interval : Pass a value of the matching C++ class GetType() property type OR the underlying enumeration type.
Note
It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved automatically from the arguments.

◆ Register() [1/3]

template<class T >
void ocilib::Statement::Register ( const ostring name)

Register a host variable as an output for a column present in a SQL RETURNING INTO clause.

Template Parameters
T- C++ type of the host variable
Parameters
name- Bind name
Warning
This method has built-in specialized versions for all supported types except:
Note
Statement, Blong and Clong are not supported for register calls
Warning
It is necessary to specify the template data type in the register call

◆ Register() [2/3]

template<class T , class U >
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.

Template Parameters
T- C++ type of the host variable
TExtraInfo- C++ type if the extra information needed for the bind call
Parameters
name- Bind name
extraInfo- Extra information needed for the bind call
Warning
This method has built-in specialized versions for Object and Reference.
It is necessary to specify the template data type in the register call

◆ Register() [3/3]

template<class T , class U >
void ocilib::Statement::Register ( const ostring name,
extraInfo 
)

Register a host variable with more information as an output for a column present in a SQL RETURNING INTO clause.

Template Parameters
T- C++ type of the host variable
TExtraInfo- C++ type if the extra information needed for the bind call
Parameters
name- Bind name
extraInfo- Extra information needed for the bind call
Warning
This method has built-in specialized versions for ostring and Raw variables. Pass the maximum length/size of variables in the parameter extraInfo
Note
It is necessary to specify the template data type in the register call

◆ GetStatementType()

Statement::StatementType ocilib::Statement::GetStatementType ( ) const
inline

Return the type of a SQL statement.

Definition at line 855 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetStatementType().

◆ GetSqlErrorPos()

unsigned int ocilib::Statement::GetSqlErrorPos ( ) const
inline

Return the error position (in terms of characters) in the SQL statement where the error occurred in case of SQL parsing error.

Note
Positions start at 1.

Definition at line 860 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetSqlErrorPos().

◆ SetFetchMode()

void ocilib::Statement::SetFetchMode ( FetchMode  value)
inline

Set the fetch mode of a SQL statement.

Parameters
value- fetch mode value
Warning
SetFetchMode() MUST be called before any Execute() call

Definition at line 865 of file Statement.hpp.

References ocilib::core::Check(), and OCI_SetFetchMode().

◆ GetFetchMode()

Statement::FetchMode ocilib::Statement::GetFetchMode ( ) const
inline

Return the fetch mode of a SQL statement.

Note
Default value is Statement::FetchForward

Definition at line 870 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetFetchMode().

◆ SetBindMode()

void ocilib::Statement::SetBindMode ( BindMode  value)
inline

Set the binding mode of a SQL statement.

Parameters
value- binding mode value

Definition at line 875 of file Statement.hpp.

References ocilib::core::Check(), and OCI_SetBindMode().

◆ GetBindMode()

Statement::BindMode ocilib::Statement::GetBindMode ( ) const
inline

Return the binding mode of a SQL statement.

Note
Default value is Statement::BindByName

Definition at line 880 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetBindMode().

◆ SetFetchSize()

void ocilib::Statement::SetFetchSize ( unsigned int  value)
inline

Set the number of rows fetched per internal server fetch call.

Parameters
value- number of rows to fetch

Definition at line 885 of file Statement.hpp.

References ocilib::core::Check(), and OCI_SetFetchSize().

◆ GetFetchSize()

unsigned int ocilib::Statement::GetFetchSize ( ) const
inline

Return the number of rows fetched per internal server fetch call.

Note
Default value is set to constant OCI_FETCH_SIZE

Definition at line 890 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetFetchSize().

◆ SetPrefetchSize()

void ocilib::Statement::SetPrefetchSize ( unsigned int  value)
inline

Set the number of rows pre-fetched by OCI Client.

Parameters
value- number of rows to pre-fetch
Note
To turn off pre-fetching, set both attributes (size and memory) to 0.

Definition at line 895 of file Statement.hpp.

References ocilib::core::Check(), and OCI_SetPrefetchSize().

◆ GetPrefetchSize()

unsigned int ocilib::Statement::GetPrefetchSize ( ) const
inline

Return the number of rows pre-fetched by OCI Client.

Note
Default value is set to constant OCI_PREFETCH_SIZE

Definition at line 900 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetPrefetchSize().

◆ SetPrefetchMemory()

void ocilib::Statement::SetPrefetchMemory ( unsigned int  value)
inline

Set the amount of memory pre-fetched by OCI Client.

Parameters
value- amount of memory to fetch
Note
Default value is 0 and the pre-fetch size attribute is used instead. When both attributes are set (pre-fetch size and memory) and pre-fetch memory value can hold more rows than specified by pre-fetch size, OCI uses pre-fetch size instead.
OCILIB set pre-fetch attribute to OCI_PREFETCH_SIZE when a statement is created. To setup a big value for SetPrefetchMemory(), you must call SetPrefetchSize() to 0 to make OCI consider this attribute.

Definition at line 905 of file Statement.hpp.

References ocilib::core::Check(), and OCI_SetPrefetchMemory().

◆ GetPrefetchMemory()

unsigned int ocilib::Statement::GetPrefetchMemory ( ) const
inline

Return the amount of memory used to retrieve rows pre-fetched by OCI Client.

Note
Default value is 0

Definition at line 910 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetPrefetchMemory().

◆ SetLongMaxSize()

void ocilib::Statement::SetLongMaxSize ( unsigned int  value)
inline

Set the LONG data type piece buffer size.

Parameters
value- maximum size for long buffer

Definition at line 915 of file Statement.hpp.

References ocilib::core::Check(), and OCI_SetLongMaxSize().

◆ GetLongMaxSize()

unsigned int ocilib::Statement::GetLongMaxSize ( ) const
inline

Return the LONG data type piece buffer size.

Note
Default value is set to constant OCI_SIZE_LONG

Definition at line 920 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetLongMaxSize().

◆ SetLongMode()

void ocilib::Statement::SetLongMode ( LongMode  value)
inline

Set the long data type handling mode of a SQL statement.

Parameters
value- long mode value
Note
LONG RAWs can't be handled with Statement::LongImplicit mode

Definition at line 925 of file Statement.hpp.

References ocilib::core::Check(), and OCI_SetLongMode().

◆ GetLongMode()

Statement::LongMode ocilib::Statement::GetLongMode ( ) const
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().

◆ GetSQLCommand()

unsigned int ocilib::Statement::GetSQLCommand ( ) const
inline

Return the Oracle SQL code the command held by the statement.

Warning
GetSQLCommand() must be called after the statement has be executed because that's the server engine that computes the SQL command code
Note
The SQL command list is available in Oracle documentations and guides

Definition at line 935 of file Statement.hpp.

References ocilib::core::Check(), and OCI_GetSQLCommand().

◆ GetSQLVerb()

ostring ocilib::Statement::GetSQLVerb ( ) const
inline

Return the verb of the SQL command held by the statement.

Warning
GetSQLVerb() must be called after the statement has been executed because that's the server engine that computes the SQL verb
Note
The SQL verb list is available in Oracle documentations and guides

Definition at line 940 of file Statement.hpp.

References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetSQLVerb().

◆ GetBatchErrors()

void ocilib::Statement::GetBatchErrors ( std::vector< Exception > &  exceptions)
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().