DCL 4.0
Loading...
Searching...
No Matches
OciConnection.h
Go to the documentation of this file.
1#ifndef __DCL_OCI_CONNECTION_H__
2#define __DCL_OCI_CONNECTION_H__ 20020321
3
4__DCL_BEGIN_NAMESPACE
5
6class OciConnection;
7class OciQuery;
8class OciField;
9class OciParam;
10
12{
14protected:
15 sword __lastStatus; // OCI.. Call Last Status
16 OCIError* __lastError;
17 ByteString __errorMessageEx; // alternative message
18 // for Define, Bind Callback
19public:
20 void setErrorStatus(
21 SQL::Error _error,
22 sword status, OCIError* pError,
23 bool bPriorReset,
24 const wchar_t* _filename, int _line
25 );
26 void setErrorEx(const ByteString& _message);
27
28 // OCI Handle Management Helper
29 sword OCIHandleAlloc(void** ppHandle, ub4 nHandleType,
30 size_t xtramem_sz = 0, void** ppvUserMem = NULL);
31 sword OCIHandleFree(void* pHandle, ub4 nHandleType);
32 sword OCIDescriptorAlloc(void** ppDescriptorHandle,
33 ub4 nDescriptorType, size_t xtramem_sz = 0, void** ppvUserMem = NULL);
34 sword OCIDescriptorFree(void* pDescriptorHandle, ub4 nDescriptorType);
35protected:
36 OCIEnv* __env;
37 OCIError* __error;
38 OCIError* __error2;
39
40 OCIServer* __server;
41 OCISvcCtx* __svcctx;
42 OCISession* __session;
43 OCITrans* __trans;
44
47
48 bool closeHelper(bool bEnableDebugInfo);
49 bool executeHelper(const char* pszSQL, size_t n);
50public:
51 OCIEnv* envHandle() const { return __env; }
52 OCIError* errorHandle() const { return __error; }
53 OCIError* errorHandle2() const { return __error2; }
54
55 OCISvcCtx* svcctxHandle() const { return __svcctx; }
56 OCISession* sessionHandle() const { return __session; }
57
58public:
59 // interface implementation
60 OciConnection(const wchar_t* _serverTitle);
61 virtual ~OciConnection();
62 virtual void destroy();
63 virtual bool __open(const char* _connString, size_t _connlen);
64 virtual bool __close();
65 virtual bool __execute(const char* _sql, size_t _sqllen);
66 virtual bool __startTrans();
67 virtual bool __commitTrans();
68 virtual bool __rollbackTrans();
69 virtual bool __createQueryInstance(SQL::Query** _queryHandleOut);
70 virtual bool __getErrorMessage(char* _buf, size_t* _buflen);
71 virtual bool __getServerInfo(char* _buf, size_t* _buflen);
72
73};
74
76 SQL::Error _error,
77 sword status, OCIError* pError,
78 bool bPriorReset,
79 const wchar_t* _filename, int _line
80 )
81{
82 Connection::setErrorStatus(_error, _filename, _line);
83
84 __lastStatus = status;
85 __lastError = pError;
86
87 if (bPriorReset && !__errorMessageEx.isEmpty())
88 __errorMessageEx.clear();
89}
90
91inline void OciConnection::setErrorEx(const ByteString& _message)
92{
93 __errorMessageEx = _message;
94 __lastStatus = 0; // OCI_SUCCESS
95 __lastError = NULL;
96}
97
98inline sword OciConnection::OCIHandleAlloc(void** ppHandle,
99 ub4 nHandleType,
100 size_t xtramem_sz /* = 0 */,
101 void** ppvUserMem /* = NULL */)
102{
104 return ::OCIHandleAlloc(__env,
105 ppHandle,
106 nHandleType,
107 xtramem_sz,
108 ppvUserMem);
109}
110
111inline sword OciConnection::OCIHandleFree(void* pHandle, ub4 nHandleType)
112{
113 __DCL_ASSERT(pHandle != NULL);
114 return ::OCIHandleFree(pHandle, nHandleType);
115}
116
117inline sword OciConnection::OCIDescriptorAlloc(void** ppDescriptorHandle,
118 ub4 nDescriptorType,
119 size_t xtramem_sz /* = 0 */,
120 void** ppvUserMem /* = NULL */)
121{
123 return ::OCIDescriptorAlloc(__env,
124 ppDescriptorHandle,
125 nDescriptorType,
126 xtramem_sz,
127 ppvUserMem);
128}
129
131 void* pDescriptorHandle,
132 ub4 nDescriptorType)
133{
134 __DCL_ASSERT(pDescriptorHandle != NULL);
135 return ::OCIDescriptorFree(pDescriptorHandle, nDescriptorType);
136}
137
138__DCL_END_NAMESPACE
139
140#endif // __DCL_OCI_CONNECTION_H__
#define NULL
Definition Config.h:340
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:210
#define __DCL_ASSERT(expr)
Definition Object.h:371
void CharsetConvertException *size_t n
Definition SQLField.cpp:253
virtual ~OciConnection()
OCISvcCtx * svcctxHandle() const
virtual void destroy()
virtual bool __getErrorMessage(char *_buf, size_t *_buflen)
bool closeHelper(bool bEnableDebugInfo)
virtual bool __startTrans()
sword OCIHandleFree(void *pHandle, ub4 nHandleType)
OCISession * __session
virtual bool __open(const char *_connString, size_t _connlen)
sword OCIDescriptorAlloc(void **ppDescriptorHandle, ub4 nDescriptorType, size_t xtramem_sz=0, void **ppvUserMem=NULL)
virtual bool __commitTrans()
OCIError * errorHandle() const
virtual bool __createQueryInstance(SQL::Query **_queryHandleOut)
OciConnection(const wchar_t *_serverTitle)
OCIServer * __server
virtual bool __execute(const char *_sql, size_t _sqllen)
OCISvcCtx * __svcctx
void setErrorStatus(SQL::Error _error, sword status, OCIError *pError, bool bPriorReset, const wchar_t *_filename, int _line)
void setErrorEx(const ByteString &_message)
virtual bool __close()
virtual bool __getServerInfo(char *_buf, size_t *_buflen)
OCIError * __error2
sword OCIDescriptorFree(void *pDescriptorHandle, ub4 nDescriptorType)
bool executeHelper(const char *pszSQL, size_t n)
sword OCIHandleAlloc(void **ppHandle, ub4 nHandleType, size_t xtramem_sz=0, void **ppvUserMem=NULL)
OCISession * sessionHandle() const
OCIError * errorHandle2() const
OCIEnv * envHandle() const
virtual bool __rollbackTrans()
OCITrans * __trans
OCIError * __error
__PROTECTED const wchar_t int _line
Definition SQLCore.h:390
__PROTECTED const wchar_t * _filename
Definition SQLCore.h:390
Error
Definition SQLCore.h:19