fintp_udal
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FinTP::OracleDatabase Class Reference

Derived OracleDatabase class to implement specific operations for Oracle Databases. More...

#include <OracleDatabase.h>

Inheritance diagram for FinTP::OracleDatabase:

Public Member Functions

 OracleDatabase ()
 
 ~OracleDatabase ()
 
void BeginTransaction (const bool readonly)
 Oracle overrides for transaction support. More...
 
void EndTransaction (const TransactionType::TRANSACTION_TYPE transactionType, const bool throwOnError)
 Ends a transaction. More...
 
void Connect (const ConnectionString &connectionString)
 Connect to database. More...
 
void Disconnect ()
 Disconnect from database. More...
 
bool IsConnected ()
 Query if Database instance is connected. More...
 
void ExecuteNonQuery (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, bool onCursor)
 Execute NonQuery SQL statements or stored procedures ( without params ) More...
 
void ExecuteNonQueryCached (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, bool onCursor)
 Execute NonQueryCached SQL statements or stored procedures ( without params ) and use caching. More...
 
void ExecuteNonQuery (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool onCursor)
 Execute NonQuery SQL statements or stored procedures ( with params ) More...
 
void ExecuteNonQueryCached (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool onCursor)
 Execute NonQueryCached SQL statements or stored procedures ( with params ) and use caching. More...
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, bool onCursor, const unsigned int fetchRows)
 Execute Query SQL statements ( without params ) More...
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool onCursor, const unsigned int fetchRows)
 Execute Query SQL statements ( with params ) More...
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const bool onCursor, const unsigned int fetchRows)
 Query SQL statements ( without params ) and use caching More...
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commType, const string &stringStatement, const ParametersVector &vectorOfParameters, const bool onCursor, const unsigned int fetchRows)
 Execute Query SQL statements ( with params ) and use caching. More...
 
void ReleaseStatement (const bool isCommandCached, const string &key)
 
void ReleaseCursor (const bool checkConn)
 If onCursor=true is passed to ExecuteQuery methods, a client is required to use these methods to release cursor resources. More...
 
void RewindCursor ()
 Rewind cursor to the first position. More...
 
- Public Member Functions inherited from FinTP::Database
 Database ()
 
virtual ~Database ()
 
void BeginTransaction ()
 
void EndTransaction (const TransactionType::TRANSACTION_TYPE transactionType)
 
void ExecuteNonQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement)
 
void ExecuteNonQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement)
 
void ExecuteNonQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters)
 
void ExecuteNonQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters)
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, bool holdCursor)
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement)
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, bool holdCursor)
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement)
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool holdCursor)
 
DataSetExecuteQuery (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters)
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters, bool holdCursor)
 
DataSetExecuteQueryCached (const DataCommand::COMMAND_TYPE commandType, const string &stringStatement, const ParametersVector &vectorOfParameters)
 
void ReleaseCursor ()
 
virtual bool CursorHeld () const
 Determines if we can hold the cursor. More...
 
int getLastNumberofAffectedRows () const
 

Private Member Functions

void BindParams (const ParametersVector &vectorOfParameters, const unsigned int startIndex=1)
 Bind parameters. More...
 
DataSetinnerExecuteCommand (const DataCommand &command, const ParametersVector &vectorOfParameters, const bool useCursor=false, const unsigned int fetchRows=0)
 
DataSetexecuteQuery (DataCommand &command, const bool isCommandCached, const bool useCursor)
 fetches data from the database, using an already created statement handle. More...
 
DataSetgetDataSet (DataCommand &command, const bool isCommandCached, OCIStmt *statementHandle, const bool useCursor)
 
void executeNonQuery (DataCommand &command, const bool isCommandCached, const bool useCursor)
 Executes the non query operation. More...
 
string getErrorInformation (dvoid *errorHandle, sword status, ub4 handleType=OCI_HTYPE_ERROR, const bool connCheck=true)
 get detailed error information. More...
 
OCIType * getMessageType (const string &typeName, const string &userName="")
 
void freeOCIArrays (const ParametersVector &vectorOfParameters)
 
void initXmlContext ()
 
string RawToString (const OCIRaw *value)
 
OCIRaw * StringToRaw (const string &value)
 
void ClearDateTimestampBinds ()
 

Static Private Member Functions

static int getOracleTransactionType (TransactionType::TRANSACTION_TYPE type)
 

Private Attributes

bool m_IsConnected
 
bool m_IsReconnecting
 
ConnectionString m_ConnectionString
 
OCIEnv * m_hEnv
 
OCIError * m_hError
 
OCISvcCtx * m_hServiceContext
 
OCISession * m_hSession
 
OCIServer * m_hServer
 
OCITrans * m_hTransaction
 
OCIStmt * m_StatementHandle
 
OCIStmt * m_hCursor
 
OCIRowid * m_HoldCursorRowId
 
xmlctx * m_XmlContext
 
OCIClobLocator * m_ClobLocator
 
OCIBlobLocator * m_BlobLocator
 
OCIClobLocator * m_FetchClobLocator
 
OCIClobLocator * m_FetchBlobLocator
 
OCIType * m_ArrayType
 
vector< OCIDate ** > m_Date
 
vector< OCIDateTime ** > m_Timestamp
 
CacheManager< string, OCIType * > m_TypeCache
 

Additional Inherited Members

- Static Public Member Functions inherited from FinTP::Database
static void DisplayDataSet (const DataSet *theDataSet)
 Utility method used to pretty print DataSet objects. More...
 
static
XERCES_CPP_NAMESPACE_QUALIFIER
DOMDocument * 
ConvertToXML (const DataSet *theDataSet, const bool doTrimm=true)
 Utility method that converts DataSet parameter objects to following XML format: <TableName> <Record> <Column_Name_n>Column_Value_n<Column_Name_n> </Record> </TableName> More...
 
- Static Public Attributes inherited from FinTP::Database
static string DateFormat = "DD.MM.YYYY"
 Used to convert a date/timestamp column to a string format database specific formats. More...
 
static string TimestampFormat = "DD.MM.YYYY HH:MI"
 
- Protected Attributes inherited from FinTP::Database
CacheManager< string, DataCommandm_StatementCache
 Collection to hold already executed Command instances. More...
 
string m_LastErrorCode
 The last error code returned from command execution. More...
 
unsigned int m_LastNumberofAffectedRows
 The number of updates last command performed. More...
 

Detailed Description

Derived OracleDatabase class to implement specific operations for Oracle Databases.

  1. First a new OracleDatabase instace is created
  2. The, the client can create a new transaction by calling BeginTransaction(readonly) method
  3. Transactions comprise one ore more calls to "ExecuteQuery" methods. Every database query is mapped to a Command instance and can be cached in m_StatementCache member of Database instance
  4. A transaction ends when the client calls EndTransaction(transactionType) performing commit or rollback on current transaction
  5. The database connection is released when Disconect() is called.

Database declare two types of "ExecuteQuery" methods

  • ExecuteQuery - Create a DataCommand from passed parameters and execute it
  • ExecuteQueryChached - Additionally, attempts to retrieve the params and resultset columns from DataCommand cache or adds them if not available

Database, define four library specific exception types to be used by its implementations

Constructor & Destructor Documentation

OracleDatabase::OracleDatabase ( )
OracleDatabase::~OracleDatabase ( )

Member Function Documentation

void OracleDatabase::BeginTransaction ( const bool  readonly)
virtual

Oracle overrides for transaction support.

Parameters
readonlytype bool.

Implements FinTP::Database.

void OracleDatabase::BindParams ( const ParametersVector vectorOfParameters,
const unsigned int  startIndex = 1 
)
private

Bind parameters.

Parameters
vectorOfParametersOptions for controlling the vector of parameters.
startIndexthe start index.
void OracleDatabase::ClearDateTimestampBinds ( )
private
void OracleDatabase::Connect ( const ConnectionString connectionString)
virtual

Connect to database.

  • allocate environment handle
  • allocate database connection handle
  • connect to database.
    Parameters
    connectionStringThe connection string to connect.

Implements FinTP::Database.

void OracleDatabase::Disconnect ( )
virtual

Disconnect from database.

  • deallocate environment handle
  • deallocate database connection handle
  • disconnect to database.

Implements FinTP::Database.

void OracleDatabase::EndTransaction ( const TransactionType::TRANSACTION_TYPE  transactionType,
const bool  throwOnError 
)
virtual

Ends a transaction.

Parameters
transactionTypeTransactionType option to close transaction
throwOnErrorBool flag to inhibit exception throwing on error.
Note
why wish not to throw exception

Implements FinTP::Database.

void FinTP::OracleDatabase::ExecuteNonQuery ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
bool  onCursor 
)
inlinevirtual

Execute NonQuery SQL statements or stored procedures ( without params )

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate through the results.
Note
Cursor description ?

Implements FinTP::Database.

void FinTP::OracleDatabase::ExecuteNonQuery ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const ParametersVector vectorOfParameters,
bool  onCursor 
)
inlinevirtual

Execute NonQuery SQL statements or stored procedures ( with params )

Parameters
commTypetype COMMAND_TYPE. The command type .
stringStatementtype string. The statement.
vectorOfParameterstype ParametersVector. The vector of parameters. Used when multiple parameters are needed.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate throught the results.
Note
Cursor description ?

Implements FinTP::Database.

void OracleDatabase::executeNonQuery ( DataCommand command,
const bool  isCommandCached,
const bool  useCursor 
)
private

Executes the non query operation.

Parameters
[in,out]commandThe command. Can be nonquery or stored procedure.
isCommandCachedDetermines if the command is cached
useCursorDetermines if a cursor is going to be used.
void FinTP::OracleDatabase::ExecuteNonQueryCached ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
bool  onCursor 
)
inlinevirtual

Execute NonQueryCached SQL statements or stored procedures ( without params ) and use caching.

Parameters
commTypetype COMMAND_TYPE. The command type
stringStatementtype string. The statement.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate throught the results.
Note
Cursor description ?

Implements FinTP::Database.

void FinTP::OracleDatabase::ExecuteNonQueryCached ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const ParametersVector vectorOfParameters,
bool  onCursor 
)
inlinevirtual

Execute NonQueryCached SQL statements or stored procedures ( with params ) and use caching.

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
vectorOfParameterstype ParametersVector. The vector of parameters. Used when multiple parameters are needed.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate throught the results.
Note
Cursor description ?

Implements FinTP::Database.

DataSet* FinTP::OracleDatabase::ExecuteQuery ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
bool  onCursor,
const unsigned int  fetchRows 
)
inlinevirtual

Execute Query SQL statements ( without params )

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate throught the results.
fetchRowstype int. The row number used in where clause.
Note
Cursor description and fetchrows descr?

Implements FinTP::Database.

DataSet* FinTP::OracleDatabase::ExecuteQuery ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const ParametersVector vectorOfParameters,
bool  onCursor,
const unsigned int  fetchRows 
)
inlinevirtual

Execute Query SQL statements ( with params )

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
vectorOfParameterstype ParametersVector. The vector of parameters. Used when multiple parameters are needed.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate throught the results.
fetchRowstype int. The row number used in where clause.
Note
Cursor description and fetchrows descr?

Implements FinTP::Database.

DataSet * OracleDatabase::executeQuery ( DataCommand command,
const bool  isCommandCached,
const bool  useCursor 
)
private

fetches data from the database, using an already created statement handle.

Parameters
[in,out]commandThe command. Can be query or stored procedure.
isCommandCachedDetermines if the command is cached.
useCursorDetermines if a cursor is going to be used.
Returns
null if the query execution fails .
DataSet* FinTP::OracleDatabase::ExecuteQueryCached ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const bool  onCursor,
const unsigned int  fetchRows 
)
inlinevirtual

Query SQL statements ( without params ) and use caching

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate throught the results.
fetchRowstype int. The row number used in where clause.
Note
Cursor description and fetchrows descr?

Implements FinTP::Database.

DataSet* FinTP::OracleDatabase::ExecuteQueryCached ( const DataCommand::COMMAND_TYPE  commType,
const string &  stringStatement,
const ParametersVector vectorOfParameters,
const bool  onCursor,
const unsigned int  fetchRows 
)
inlinevirtual

Execute Query SQL statements ( with params ) and use caching.

Parameters
commTypetype COMMAND_TYPE. The command type.
stringStatementtype string. The statement.
vectorOfParameterstype ParametersVector. The vector of parameters. Used when multiple parameters are needed.
onCursortype bool. Determine if the function will use an Oracle cursor to iterate throught the results.
fetchRowstype int. The row number used in where clause.
Note
Cursor description and fetchrows descr?

Releases the statement.

Parameters
isCommandCachedThe is command cached.
keyThe key associated with the statement in the cache.

Implements FinTP::Database.

void OracleDatabase::freeOCIArrays ( const ParametersVector vectorOfParameters)
private
DataSet * OracleDatabase::getDataSet ( DataCommand command,
const bool  isCommandCached,
OCIStmt *  statementHandle,
const bool  useCursor 
)
private
string OracleDatabase::getErrorInformation ( dvoid *  errorHandle,
sword  status,
ub4  handleType = OCI_HTYPE_ERROR,
const bool  connCheck = true 
)
private

get detailed error information.

Parameters
[in,out]errorHandleIf non-null, handle of the error.
statusThe status.
handleTypeThe type of the handle.
connCheckThe connection check.
Returns
The error information.
OCIType * OracleDatabase::getMessageType ( const string &  typeName,
const string &  userName = "" 
)
private
int OracleDatabase::getOracleTransactionType ( TransactionType::TRANSACTION_TYPE  type)
staticprivate
void OracleDatabase::initXmlContext ( )
private
DataSet * OracleDatabase::innerExecuteCommand ( const DataCommand command,
const ParametersVector vectorOfParameters,
const bool  useCursor = false,
const unsigned int  fetchRows = 0 
)
private
bool OracleDatabase::IsConnected ( )
virtual

Query if Database instance is connected.

Returns
true if connected, false if not.

Implements FinTP::Database.

string OracleDatabase::RawToString ( const OCIRaw *  value)
private
void OracleDatabase::ReleaseCursor ( const bool  checkConn)
virtual

If onCursor=true is passed to ExecuteQuery methods, a client is required to use these methods to release cursor resources.

Parameters
checkConntrue to check connection.

Implements FinTP::Database.

void OracleDatabase::ReleaseStatement ( const bool  isCommandCached,
const string &  key 
)
void FinTP::OracleDatabase::RewindCursor ( )
inlinevirtual

Rewind cursor to the first position.

Implements FinTP::Database.

OCIRaw * OracleDatabase::StringToRaw ( const string &  value)
private

Member Data Documentation

OCIType* FinTP::OracleDatabase::m_ArrayType
private
OCIBlobLocator* FinTP::OracleDatabase::m_BlobLocator
private
OCIClobLocator* FinTP::OracleDatabase::m_ClobLocator
private
ConnectionString FinTP::OracleDatabase::m_ConnectionString
private
vector< OCIDate** > FinTP::OracleDatabase::m_Date
private
OCIClobLocator* FinTP::OracleDatabase::m_FetchBlobLocator
private
OCIClobLocator* FinTP::OracleDatabase::m_FetchClobLocator
private
OCIStmt* FinTP::OracleDatabase::m_hCursor
private
OCIEnv* FinTP::OracleDatabase::m_hEnv
private
OCIError* FinTP::OracleDatabase::m_hError
private
OCIRowid* FinTP::OracleDatabase::m_HoldCursorRowId
private
OCIServer* FinTP::OracleDatabase::m_hServer
private
OCISvcCtx* FinTP::OracleDatabase::m_hServiceContext
private
OCISession* FinTP::OracleDatabase::m_hSession
private
OCITrans* FinTP::OracleDatabase::m_hTransaction
private
bool FinTP::OracleDatabase::m_IsConnected
private
bool FinTP::OracleDatabase::m_IsReconnecting
private
OCIStmt* FinTP::OracleDatabase::m_StatementHandle
private
vector< OCIDateTime** > FinTP::OracleDatabase::m_Timestamp
private
CacheManager< string, OCIType* > FinTP::OracleDatabase::m_TypeCache
private
xmlctx* FinTP::OracleDatabase::m_XmlContext
private

The documentation for this class was generated from the following files: