DCL 3.7.4
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 __errorMessage; // alternative message
18 // for Define, Bind Callback
19public:
20 // _priorReset setErrorMessage를 통해 설정한 메시지를 reset한다.
21 // Define, Bind Callback은 OCIExecute, OCIFetch가 호출 될 때 실행된다.
22 // OCIExecute, OCIFetch의 OCI_ERROR에 대한 상세 메시지는 __errorMessage에 있을 수 있다.
23 // 만약, __lastStatus OCI_SUCCESS(0)이고, __lastError가 NULL 이면 독립된 오류이다.
24 void setErrorHandle(
25 SQL::Error _error,
26 sword _status, OCIError* _OCIError,
27 bool _priorReset,
28 const wchar_t* _filename, int _line
29 );
30
31 void setErrorMessage(
32 const ByteString& _message,
33 const wchar_t* _filename, int _line
34 );
35
36 // OCI Handle Management Helper
37 sword HandleAlloc(
38 void** _hndlpp,
39 ub4 _type,
40 size_t _xtramem_sz = 0,
41 void** _usrmempp = NULL
42 );
43
44 sword HandleFree(
45 void* _hndlp,
46 ub4 _type
47 );
48
49 sword DescriptorAlloc(
50 void** _descpp,
51 ub4 _type,
52 size_t _xtramem_sz = 0,
53 void** _usrmempp = NULL
54 );
55
56 sword DescriptorFree(
57 void* _descp,
58 ub4 _type
59 );
60
61protected:
62 OCIEnv* __env;
63 OCIError* __error;
64 OCIError* __error2;
65
66 OCIServer* __server;
67 OCISvcCtx* __svcctx;
68 OCISession* __session;
69 OCITrans* __trans;
70
73
74 bool closeHelper(bool bEnableDebugInfo);
75 bool executeHelper(const char* _sql, size_t _sqllen);
76public:
77 OCIEnv* envHandle() const { return __env; }
78 OCIError* errorHandle() const { return __error; }
79 OCIError* errorHandle2() const { return __error2; }
80
81 OCISvcCtx* svcHandle() const { return __svcctx; }
82 OCISession* sessionHandle() const { return __session; }
83
84public:
85 // interface implementation
86 OciConnection(const wchar_t* _serverTitle);
87 virtual ~OciConnection();
88 virtual void destroy();
89 virtual bool __open(const char* _cons, size_t _conslen);
90 virtual bool __close();
91 virtual bool __execute(const char* _sql, size_t _sqllen);
92 virtual bool __startTrans();
93 virtual bool __commitTrans();
94 virtual bool __rollbackTrans();
95 virtual bool __createQueryInstance(SQL::Query** _queryHandleOut);
96 virtual bool __getErrorMessage(char* _buf, size_t* _buflen);
97 virtual bool __getServerInfo(char* _buf, size_t* _buflen);
98
99};
100
102 SQL::Error _error,
103 sword status, OCIError* pError,
104 bool _priorReset,
105 const wchar_t* _filename, int _line
106 )
107{
108 Connection::setErrorStatus(_error, _filename, _line);
109
110 __lastStatus = status;
111 __lastError = pError;
112
113 if (_priorReset)
114 __errorMessage.clear();
115}
116
118 const ByteString& _message,
119 const wchar_t* _filename, int _line
120 )
121{
122 Connection::setErrorStatus(SQL::eServerError, _filename, _line);
123
124 __errorMessage = _message;
125 __lastStatus = 0; // OCI_SUCCESS
126 __lastError = NULL;
127}
128
130 void** _hndlpp,
131 ub4 _type,
132 size_t _xtramem_sz, // = 0,
133 void** _usrmempp // = NULL
134 )
135{
137 return OCIHandleAlloc(
138 __env, // const void *parenth
139 _hndlpp, // void **hndlpp
140 _type, // ub4 type
141 _xtramem_sz, // size_t xtramem_sz
142 _usrmempp // void **usrmempp
143 );
144}
145
147 void* _hndlp,
148 ub4 _type
149 )
150{
151 __DCL_ASSERT(_hndlp != NULL);
152 return OCIHandleFree(
153 _hndlp, // void *hndlp
154 _type // ub4 type
155 );
156}
157
159 void** _descpp,
160 ub4 _type,
161 size_t _xtramem_sz, // = 0,
162 void** _usrmempp // = NULL
163 )
164{
166 return OCIDescriptorAlloc(
167 __env, // const void* parenth,
168 _descpp, // void** descpp,
169 _type, // ub4 type,
170 _xtramem_sz, // size_t xtramem_sz,
171 _usrmempp // void** usrmempp
172 );
173}
174
176 void* _descp,
177 ub4 _type
178 )
179{
180 __DCL_ASSERT(_descp != NULL);
181 return OCIDescriptorFree(
182 _descp, // void* descp,
183 _type // ub4 type
184 );
185}
186
187__DCL_END_NAMESPACE
188
189#endif // __DCL_OCI_CONNECTION_H__
#define NULL
Definition Config.h:312
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:227
#define __DCL_ASSERT(expr)
Definition Object.h:394
virtual bool __open(const char *_cons, size_t _conslen)
virtual ~OciConnection()
void setErrorMessage(const ByteString &_message, const wchar_t *_filename, int _line)
virtual void destroy()
virtual bool __getErrorMessage(char *_buf, size_t *_buflen)
bool closeHelper(bool bEnableDebugInfo)
virtual bool __startTrans()
OCISession * __session
virtual bool __commitTrans()
OCIError * errorHandle() const
virtual bool __createQueryInstance(SQL::Query **_queryHandleOut)
OciConnection(const wchar_t *_serverTitle)
bool executeHelper(const char *_sql, size_t _sqllen)
OCIServer * __server
virtual bool __execute(const char *_sql, size_t _sqllen)
OCISvcCtx * __svcctx
virtual bool __close()
OCISvcCtx * svcHandle() const
virtual bool __getServerInfo(char *_buf, size_t *_buflen)
OCIError * __error2
void setErrorHandle(SQL::Error _error, sword _status, OCIError *_OCIError, bool _priorReset, const wchar_t *_filename, int _line)
sword DescriptorAlloc(void **_descpp, ub4 _type, size_t _xtramem_sz=0, void **_usrmempp=NULL)
sword DescriptorFree(void *_descp, ub4 _type)
OCISession * sessionHandle() const
OCIError * errorHandle2() const
sword HandleAlloc(void **_hndlpp, ub4 _type, size_t _xtramem_sz=0, void **_usrmempp=NULL)
OCIEnv * envHandle() const
virtual bool __rollbackTrans()
OCITrans * __trans
sword HandleFree(void *_hndlp, ub4 _type)
OCIError * __error
_PROTECTED const wchar_t * _filename
Definition SQLCore.h:439
_PROTECTED const wchar_t int _line
Definition SQLCore.h:441
Error
Definition SQLCore.h:19
@ eServerError
Definition SQLCore.h:21