blob: 392f057e4c2ac43e66e259e21126a4709b44b4c9 [file] [log] [blame]
Tang Cheng37650ea2014-10-20 16:14:41 +08001/* Copyright Oracle Corporation 2000, 2006. All Rights Reserved. */
2
3/*
4 NAME
5 occiControl.h - header file for OCCI control classes
6
7 DESCRIPTION
8 Class definitions for MetaData,SQLException,Environment,
9 Connection,Statement, ConnectionPool, StatelessConnectionPool
10
11 RELATED DOCUMENTS
12 <note any documents related to this facility>
13
14 EXPORT FUNCTION(S)
15 <external functions declared for use outside package - one-line
16 descriptions>
17
18 INTERNAL FUNCTION(S)
19 <other external functions declared - one-line descriptions>
20
21 EXAMPLES
22
23 NOTES
24 <other useful comments, qualifications, etc.>
25
26
27*/
28
29#ifndef _olint /* disable olint check */
30
31#ifndef OCCICONTROL_ORACLE
32# define OCCICONTROL_ORACLE
33
34#ifndef OCCICOMMON_ORACLE
35#include <occiCommon.h>
36#endif
37
38#ifndef ORAEXCEPTION
39#define ORAEXCEPTION
40#include <exception>
41#endif
42
43namespace oracle {
44namespace occi {
45/*---------------------------------------------------------------------------
46 PUBLIC TYPES AND CONSTANTS
47 ---------------------------------------------------------------------------*/
48
49class MetaData
50{
51 public :
52
53 enum AttrId
54 {ATTR_PTYPE = OCI_ATTR_PTYPE,
55 ATTR_TIMESTAMP = OCI_ATTR_TIMESTAMP,
56 ATTR_OBJ_ID = OCI_ATTR_OBJ_ID,
57 ATTR_OBJ_NAME = OCI_ATTR_OBJ_NAME,
58 ATTR_OBJ_SCHEMA = OCI_ATTR_OBJ_SCHEMA,
59 ATTR_OBJID = OCI_ATTR_OBJID,
60 ATTR_NUM_COLS = OCI_ATTR_NUM_COLS,
61 ATTR_LIST_COLUMNS = OCI_ATTR_LIST_COLUMNS,
62 ATTR_REF_TDO = OCI_ATTR_REF_TDO,
63 ATTR_IS_TEMPORARY = OCI_ATTR_IS_TEMPORARY,
64 ATTR_IS_TYPED = OCI_ATTR_IS_TYPED,
65 ATTR_DURATION = OCI_ATTR_DURATION,
66 ATTR_COLLECTION_ELEMENT = OCI_ATTR_COLLECTION_ELEMENT,
67 ATTR_RDBA = OCI_ATTR_RDBA,
68 ATTR_TABLESPACE = OCI_ATTR_TABLESPACE,
69 ATTR_CLUSTERED = OCI_ATTR_CLUSTERED,
70 ATTR_PARTITIONED = OCI_ATTR_PARTITIONED,
71 ATTR_INDEX_ONLY = OCI_ATTR_INDEX_ONLY,
72 ATTR_LIST_ARGUMENTS = OCI_ATTR_LIST_ARGUMENTS,
73 ATTR_IS_INVOKER_RIGHTS = OCI_ATTR_IS_INVOKER_RIGHTS,
74 ATTR_LIST_SUBPROGRAMS = OCI_ATTR_LIST_SUBPROGRAMS,
75 ATTR_NAME = OCI_ATTR_NAME,
76 ATTR_OVERLOAD_ID = OCI_ATTR_OVERLOAD_ID,
77 ATTR_TYPECODE = OCI_ATTR_TYPECODE,
78 ATTR_COLLECTION_TYPECODE = OCI_ATTR_COLLECTION_TYPECODE,
79 ATTR_VERSION = OCI_ATTR_VERSION,
80 ATTR_IS_INCOMPLETE_TYPE = OCI_ATTR_IS_INCOMPLETE_TYPE,
81 ATTR_IS_SYSTEM_TYPE = OCI_ATTR_IS_SYSTEM_TYPE,
82 ATTR_IS_PREDEFINED_TYPE = OCI_ATTR_IS_PREDEFINED_TYPE,
83 ATTR_IS_TRANSIENT_TYPE = OCI_ATTR_IS_TRANSIENT_TYPE,
84 ATTR_IS_SYSTEM_GENERATED_TYPE =
85 OCI_ATTR_IS_SYSTEM_GENERATED_TYPE,
86 ATTR_HAS_NESTED_TABLE = OCI_ATTR_HAS_NESTED_TABLE,
87 ATTR_HAS_LOB = OCI_ATTR_HAS_LOB,
88 ATTR_HAS_FILE = OCI_ATTR_HAS_FILE,
89 ATTR_NUM_TYPE_ATTRS = OCI_ATTR_NUM_TYPE_ATTRS,
90 ATTR_LIST_TYPE_ATTRS = OCI_ATTR_LIST_TYPE_ATTRS,
91 ATTR_NUM_TYPE_METHODS = OCI_ATTR_NUM_TYPE_METHODS,
92 ATTR_LIST_TYPE_METHODS = OCI_ATTR_LIST_TYPE_METHODS,
93 ATTR_MAP_METHOD = OCI_ATTR_MAP_METHOD,
94 ATTR_ORDER_METHOD = OCI_ATTR_ORDER_METHOD,
95 ATTR_DATA_SIZE = OCI_ATTR_DATA_SIZE,
96 ATTR_DATA_TYPE = OCI_ATTR_DATA_TYPE,
97 ATTR_PRECISION = OCI_ATTR_PRECISION,
98 ATTR_SCALE = OCI_ATTR_SCALE,
99 ATTR_TYPE_NAME = OCI_ATTR_TYPE_NAME,
100 ATTR_SCHEMA_NAME = OCI_ATTR_SCHEMA_NAME,
101 ATTR_CHARSET_ID = OCI_ATTR_CHARSET_ID,
102 ATTR_CHARSET_FORM = OCI_ATTR_CHARSET_FORM,
103 ATTR_ENCAPSULATION = OCI_ATTR_ENCAPSULATION,
104 ATTR_IS_CONSTRUCTOR = OCI_ATTR_IS_CONSTRUCTOR,
105 ATTR_IS_DESTRUCTOR = OCI_ATTR_IS_DESTRUCTOR,
106 ATTR_IS_OPERATOR = OCI_ATTR_IS_OPERATOR,
107 ATTR_IS_SELFISH = OCI_ATTR_IS_SELFISH,
108 ATTR_IS_MAP = OCI_ATTR_IS_MAP,
109 ATTR_IS_ORDER = OCI_ATTR_IS_ORDER,
110 ATTR_IS_RNDS = OCI_ATTR_IS_RNDS,
111 ATTR_IS_RNPS = OCI_ATTR_IS_RNPS,
112 ATTR_IS_WNDS = OCI_ATTR_IS_WNDS,
113 ATTR_IS_WNPS = OCI_ATTR_IS_WNPS,
114 ATTR_NUM_ELEMS = OCI_ATTR_NUM_ELEMS,
115 ATTR_LINK = OCI_ATTR_LINK,
116 ATTR_MIN = OCI_ATTR_MIN,
117 ATTR_MAX = OCI_ATTR_MAX,
118 ATTR_INCR = OCI_ATTR_INCR,
119 ATTR_CACHE = OCI_ATTR_CACHE,
120 ATTR_ORDER = OCI_ATTR_ORDER,
121 ATTR_HW_MARK = OCI_ATTR_HW_MARK,
122 ATTR_IS_NULL = OCI_ATTR_IS_NULL,
123 ATTR_POSITION = OCI_ATTR_POSITION,
124 ATTR_HAS_DEFAULT = OCI_ATTR_HAS_DEFAULT,
125 ATTR_LEVEL = OCI_ATTR_LEVEL,
126 ATTR_IOMODE = OCI_ATTR_IOMODE,
127 ATTR_RADIX = OCI_ATTR_RADIX,
128 ATTR_SUB_NAME = OCI_ATTR_SUB_NAME,
129 ATTR_LIST_OBJECTS = OCI_ATTR_LIST_OBJECTS,
130 ATTR_NCHARSET_ID = OCI_ATTR_NCHARSET_ID,
131 ATTR_LIST_SCHEMAS = OCI_ATTR_LIST_SCHEMAS,
132 ATTR_MAX_PROC_LEN = OCI_ATTR_MAX_PROC_LEN,
133 ATTR_MAX_COLUMN_LEN = OCI_ATTR_MAX_COLUMN_LEN,
134 ATTR_CURSOR_COMMIT_BEHAVIOR =
135 OCI_ATTR_CURSOR_COMMIT_BEHAVIOR,
136 ATTR_MAX_CATALOG_NAMELEN = OCI_ATTR_MAX_CATALOG_NAMELEN,
137 ATTR_CATALOG_LOCATION = OCI_ATTR_CATALOG_LOCATION,
138 ATTR_SAVEPOINT_SUPPORT = OCI_ATTR_SAVEPOINT_SUPPORT,
139 ATTR_NOWAIT_SUPPORT = OCI_ATTR_NOWAIT_SUPPORT,
140 ATTR_AUTOCOMMIT_DDL = OCI_ATTR_AUTOCOMMIT_DDL,
141 ATTR_LOCKING_MODE = OCI_ATTR_LOCKING_MODE,
142 ATTR_IS_FINAL_TYPE = OCI_ATTR_IS_FINAL_TYPE,
143 ATTR_IS_INSTANTIABLE_TYPE = OCI_ATTR_IS_INSTANTIABLE_TYPE,
144 ATTR_IS_SUBTYPE = OCI_ATTR_IS_SUBTYPE,
145 ATTR_SUPERTYPE_SCHEMA_NAME = OCI_ATTR_SUPERTYPE_SCHEMA_NAME,
146 ATTR_SUPERTYPE_NAME = OCI_ATTR_SUPERTYPE_NAME,
147 ATTR_FSPRECISION = OCI_ATTR_FSPRECISION,
148 ATTR_LFPRECISION = OCI_ATTR_LFPRECISION,
149 ATTR_IS_FINAL_METHOD = OCI_ATTR_IS_FINAL_METHOD,
150 ATTR_IS_INSTANTIABLE_METHOD = OCI_ATTR_IS_INSTANTIABLE_METHOD,
151 ATTR_IS_OVERRIDING_METHOD = OCI_ATTR_IS_OVERRIDING_METHOD,
152 ATTR_CHAR_USED = OCI_ATTR_CHAR_USED,
153 ATTR_CHAR_SIZE = OCI_ATTR_CHAR_SIZE,
154 ATTR_COL_ENC = OCI_ATTR_COL_ENC,
155 ATTR_COL_ENC_SALT = OCI_ATTR_COL_ENC_SALT,
156 ATTR_TABLE_ENC = OCI_ATTR_TABLE_ENC,
157 ATTR_TABLE_ENC_ALG = OCI_ATTR_TABLE_ENC_ALG,
158 ATTR_TABLE_ENC_ALG_ID = OCI_ATTR_TABLE_ENC_ALG_ID
159 };
160
161 enum ParamType
162 {
163 PTYPE_TABLE = OCI_PTYPE_TABLE
164 ,PTYPE_VIEW = OCI_PTYPE_VIEW
165 ,PTYPE_PROC = OCI_PTYPE_PROC
166 ,PTYPE_FUNC = OCI_PTYPE_FUNC
167 ,PTYPE_PKG = OCI_PTYPE_PKG
168 ,PTYPE_TYPE = OCI_PTYPE_TYPE
169 ,PTYPE_TYPE_ATTR = OCI_PTYPE_TYPE_ATTR
170 ,PTYPE_TYPE_COLL = OCI_PTYPE_TYPE_COLL
171 ,PTYPE_TYPE_METHOD = OCI_PTYPE_TYPE_METHOD
172 ,PTYPE_SYN = OCI_PTYPE_SYN
173 ,PTYPE_SEQ = OCI_PTYPE_SEQ
174 ,PTYPE_COL = OCI_PTYPE_COL
175 ,PTYPE_ARG = OCI_PTYPE_ARG
176 ,PTYPE_TYPE_ARG = OCI_PTYPE_TYPE_ARG
177 ,PTYPE_TYPE_RESULT = OCI_PTYPE_TYPE_RESULT
178 ,PTYPE_SCHEMA = OCI_PTYPE_SCHEMA
179 ,PTYPE_DATABASE = OCI_PTYPE_DATABASE
180 ,PTYPE_UNK = OCI_PTYPE_UNK
181 };
182
183
184 enum { DURATION_SESSION = OCI_DURATION_SESSION
185 ,DURATION_TRANS = OCI_DURATION_TRANS
186 ,DURATION_NULL = OCI_DURATION_NULL
187 ,TYPEENCAP_PRIVATE = OCI_TYPEENCAP_PRIVATE
188 ,TYPEENCAP_PUBLIC = OCI_TYPEENCAP_PUBLIC
189 ,TYPEPARAM_IN = OCI_TYPEPARAM_IN
190 ,TYPEPARAM_OUT = OCI_TYPEPARAM_OUT
191 ,TYPEPARAM_INOUT = OCI_TYPEPARAM_INOUT
192 ,CURSOR_OPEN = OCI_CURSOR_OPEN
193 ,CURSOR_CLOSED = OCI_CURSOR_CLOSED
194 ,CL_START = OCI_CL_START
195 ,CL_END = OCI_CL_END
196 ,SP_SUPPORTED = OCI_SP_SUPPORTED
197 ,SP_UNSUPPORTED = OCI_SP_UNSUPPORTED
198 ,NW_SUPPORTED = OCI_NW_SUPPORTED
199 ,NW_UNSUPPORTED = OCI_NW_UNSUPPORTED
200 ,AC_DDL = OCI_AC_DDL
201 ,NO_AC_DDL = OCI_NO_AC_DDL
202 ,LOCK_IMMEDIATE = OCI_LOCK_IMMEDIATE
203 ,LOCK_DELAYED = OCI_LOCK_DELAYED
204 };
205
206 MetaData(const MetaData &omd);
207 unsigned int getAttributeCount() const
208 ;
209 AttrId getAttributeId(unsigned int attributenum) const
210 ;
211 Type getAttributeType(unsigned int attributenum) const
212 ;
213 int getInt(MetaData::AttrId attrid) const
214 ;
215 bool getBoolean(MetaData::AttrId attrid) const
216 ;
217 unsigned int getUInt(MetaData::AttrId attrid) const
218 ;
219 OCCI_STD_NAMESPACE::string getString(MetaData::AttrId attrid) const
220 ;
221 UString getUString(MetaData::AttrId attrid) const
222 ;
223 Number getNumber(MetaData::AttrId attrid) const
224 ;
225 RefAny getRef(MetaData::AttrId attrid) const
226 ;
227 Timestamp getTimestamp(MetaData::AttrId attrid) const
228 ;
229 MetaData getMetaData(MetaData::AttrId attrid) const
230 ;
231 OCCI_STD_NAMESPACE::vector<MetaData> getVector(MetaData::AttrId attrid)
232 const ;
233 void operator =(const MetaData &omd);
234
235 ~MetaData();
236
237 private:
238
239 enum ociAttrType { OCI_UB1,
240 OCI_UB2,
241 OCI_UB4,
242 OCI_SB1,
243 OCI_WORD,
244 OCI_UB1_BOOL,
245 OCI_UB1PTR_TIMESTAMP,
246 OCI_UB1PTR_NUMBER,
247 OCI_TEXTPTR,
248 OCI_DVOIDPTR_PARAM,
249 OCI_DVOIDPTR_PARAMLIST,
250 OCI_OCIREFPTR,
251 OCI_OCIDURATION,
252 OCI_OCITYPECODE,
253 OCI_OCITYPEENCAP,
254 OCI_OCITYPEPARAMMODE,
255 OCI_OCIPRECISION
256 };
257
258 enum AttrCount {COMMON_ATTR_COUNT = 5,
259 TABLE_ATTR_COUNT = 15,
260 VIEW_ATTR_COUNT = 7,
261 FUNCPROC_ATTR_COUNT = 4,
262 PKG_ATTR_COUNT = 2,
263 TYP_ATTR_COUNT = 27,
264 TYPEATTR_ATTR_COUNT = 14,
265 TYPEMTHD_ATTR_COUNT = 16,
266 COLL_ATTR_COUNT = 12,
267 SYN_ATTR_COUNT = 4,
268 SEQ_ATTR_COUNT = 7,
269 COL_ATTR_COUNT = 15,
270 ARG_TYPARG_TYPRES_ATTR_COUNT = 20,
271 SCHEMA_ATTR_COUNT = 1,
272 DATABASE_ATTR_COUNT = 13,
273 UNK_ATTR_COUNT = 0
274 };
275
276 static const AttrId commonAttrId[COMMON_ATTR_COUNT];
277 static const ociAttrType commonAttrType[COMMON_ATTR_COUNT];
278 static const AttrId tableAttrId[TABLE_ATTR_COUNT];
279 static const ociAttrType tableAttrType[TABLE_ATTR_COUNT];
280 static const AttrId viewAttrId[VIEW_ATTR_COUNT];
281 static const ociAttrType viewAttrType[VIEW_ATTR_COUNT];
282 static const AttrId funcprocAttrId[FUNCPROC_ATTR_COUNT];
283 static const ociAttrType funcprocAttrType[FUNCPROC_ATTR_COUNT];
284 static const AttrId pkgAttrId[PKG_ATTR_COUNT];
285 static const ociAttrType pkgAttrType[PKG_ATTR_COUNT];
286 static const AttrId typAttrId[TYP_ATTR_COUNT];
287 static const ociAttrType typAttrType[TYP_ATTR_COUNT];
288 static const AttrId typeattrAttrId[TYPEATTR_ATTR_COUNT];
289 static const ociAttrType typeattrAttrType[TYPEATTR_ATTR_COUNT];
290 static const AttrId typmethdAttrId[TYPEMTHD_ATTR_COUNT];
291 static const ociAttrType typemthdAttrType[TYPEMTHD_ATTR_COUNT];
292 static const AttrId collAttrId[COLL_ATTR_COUNT];
293 static const ociAttrType collAttrType[COLL_ATTR_COUNT];
294 static const AttrId synAttrId[SYN_ATTR_COUNT];
295 static const ociAttrType synAttrType[SYN_ATTR_COUNT];
296 static const AttrId seqAttrId[SEQ_ATTR_COUNT];
297 static const ociAttrType seqAttrType[SEQ_ATTR_COUNT];
298 static const AttrId colAttrId[COL_ATTR_COUNT];
299 static const ociAttrType colAttrType[COL_ATTR_COUNT];
300 static const AttrId argtargtresAttrId[ARG_TYPARG_TYPRES_ATTR_COUNT];
301 static const ociAttrType argtargtresAttrType[
302 ARG_TYPARG_TYPRES_ATTR_COUNT];
303 static const AttrId schemaAttrId[SCHEMA_ATTR_COUNT];
304 static const ociAttrType schemaAttrType[SCHEMA_ATTR_COUNT];
305 static const AttrId databaseAttrId[DATABASE_ATTR_COUNT];
306 static const ociAttrType databaseAttrType[DATABASE_ATTR_COUNT];
307
308 Ptr<MetaDataImpl> metaDataImplPtr;
309 const OCIParam* paramhp;
310 const ConnectionImpl* sesn;
311 const AttrId* attrIdArray;
312 const ociAttrType* attrTypeArray;
313 AttrCount attrCount;
314
315 MetaData(const Connection *sessp, const OCCI_STD_NAMESPACE::string& objName,
316 ParamType prmtyp ) ;
317 MetaData(const Connection *sessp, const UString& objName,
318 ParamType prmtyp ) ;
319 MetaData(const Connection *sessp,
320 const RefAny& ref) ;
321 MetaData(const Connection *sessp, MetaDataImpl *implPtr,
322 OCIParam* parm) ;
323 MetaData(const Connection *sessp, MetaDataImpl *implPtr,
324 OCIParam *parm, ub1 parmTyp) ;
325 ub1 getParamType(OCIParam* prm) const ;
326 const AttrId* getAttrIdArrayAddr(ub1 prmTyp) const;
327 const ociAttrType* getAttrTypeArrayAddr(ub1 prmTyp) const;
328 AttrCount getAttrCount(ub1 prmTyp) const;
329 Type getType(ociAttrType typ) const;
330 bool isListTypeAttribute(AttrId attrid,ub1 ptyp) const;
331 boolean isInvalidAttrId(AttrId attrid,sb4* pos,
332 boolean* isTypeSpecificAttrPtr) const;
333 ociAttrType getValidAttrType(sb4 index, boolean isTypeSpecificAttr)
334 const;
335
336 int getListType (const OCIParam *plist) const;
337 unsigned int getLowerBound(int ltype) const;
338 unsigned int getUpperBound(unsigned int ltype,
339 unsigned int paramnum) const;
340 friend class ConnectionImpl;
341 friend class ResultSetImpl;
342
343};
344
345//return codes for user callbacks
346enum
347{
348 OCCI_SUCCESS = OCI_SUCCESS,
349 FO_RETRY = OCI_FO_RETRY
350};
351
352
353class Connection
354{
355 public :
356
357 // specifies the type of proxy to be created,
358 // used for future enhancements
359 enum ProxyType
360 {PROXY_DEFAULT
361 };
362
363 enum FailOverType
364 {
365 FO_NONE = OCI_FO_NONE,
366 FO_SESSION = OCI_FO_SESSION,
367 FO_SELECT = OCI_FO_SELECT
368 };
369
370 enum FailOverEventType
371 {
372 FO_BEGIN = OCI_FO_BEGIN,
373 FO_END = OCI_FO_END,
374 FO_ABORT = OCI_FO_ABORT,
375 FO_REAUTH = OCI_FO_REAUTH,
376 FO_ERROR = OCI_FO_ERROR
377 };
378
379 enum Purity
380 {
381 DEFAULT = OCI_ATTR_PURITY_DEFAULT,
382 NEW = OCI_ATTR_PURITY_NEW,
383 SELF = OCI_ATTR_PURITY_SELF
384 };
385
386 virtual ~Connection() { }
387 virtual Statement* createStatement(
388 const OCCI_STD_NAMESPACE::string &sql = "")
389 =0;
390 virtual void terminateStatement(Statement *statement) =0;
391 virtual void commit() =0;
392 virtual void rollback() =0;
393 virtual MetaData getMetaData(const OCCI_STD_NAMESPACE::string &object,
394 MetaData::ParamType prmtyp
395 = MetaData::PTYPE_UNK) const
396 =0;
397 virtual MetaData getMetaData(const RefAny &ref) const
398 =0;
399 virtual OCCI_STD_NAMESPACE::string getClientCharSet() const
400 =0;
401 virtual OCCI_STD_NAMESPACE::string getClientNCHARCharSet() const
402 =0;
403 virtual void changePassword(const OCCI_STD_NAMESPACE::string &user,
404 const OCCI_STD_NAMESPACE::string &oldPassword,
405 const OCCI_STD_NAMESPACE::string &newPassword)
406 =0;
407 virtual void flushCache() =0;
408
409 virtual OCIServer* getOCIServer() const =0;
410 virtual OCISvcCtx* getOCIServiceContext() const =0;
411 virtual OCISession* getOCISession() const =0;
412
413 //new interfaces
414
415 virtual Statement* createStatement(const UString &sql) = 0;
416 virtual MetaData getMetaData(const UString &object,
417 MetaData::ParamType prmtyp
418 = MetaData::PTYPE_UNK) const
419 =0;
420 virtual UString getClientCharSetUString() const
421 =0;
422 virtual UString getClientNCHARCharSetUString() const
423 =0;
424 virtual void changePassword(const UString &user,
425 const UString &oldPassword,
426 const UString &newPassword)
427 =0;
428 virtual OCCI_STD_NAMESPACE::string getTag() const =0;
429 virtual void setStmtCacheSize(unsigned int cacheSize) = 0;
430 virtual unsigned int getStmtCacheSize() const =0;
431 virtual Statement* createStatement(const OCCI_STD_NAMESPACE::string &sql,
432 const OCCI_STD_NAMESPACE::string &tag) = 0;
433 virtual void terminateStatement(Statement* stmt,
434 const OCCI_STD_NAMESPACE::string &tag) = 0;
435 virtual bool isCached(const OCCI_STD_NAMESPACE::string &sql,
436 const OCCI_STD_NAMESPACE::string &tag = "") = 0;
437 virtual void registerSubscriptions(
438 const OCCI_STD_NAMESPACE::vector<aq::Subscription>& sub) =0;
439 virtual void unregisterSubscription(const aq::Subscription& sub) =0;
440 virtual void postToSubscriptions(
441 const OCCI_STD_NAMESPACE::vector<aq::Subscription>& sub) =0;
442 virtual Statement* createStatement(const UString &sql,
443 const UString &tag) = 0;
444 virtual void terminateStatement(Statement* stmt,
445 const UString &tag) = 0;
446 virtual bool isCached(const UString &sql,
447 const UString &tag) = 0;
448 virtual void setTAFNotify(
449 int (*notifyFn)(Environment *env, Connection *conn, void *ctx,
450 FailOverType foType, FailOverEventType foEvent),
451 void *ctx) = 0;
452 virtual OCCI_STD_NAMESPACE::string getServerVersion() const =0;
453 virtual UString getServerVersionUString() const =0;
454 virtual void cancel() =0;
455};
456
457class StatelessConnectionPool
458{
459 public :
460
461 enum PoolType
462 {
463 HETEROGENEOUS = OCI_DEFAULT,
464 HOMOGENEOUS = OCI_SPC_HOMOGENEOUS,
465 NO_RLB = OCI_SPC_NO_RLB,
466 USES_EXT_AUTH = 16
467 };
468
469 enum BusyOption
470 {
471 WAIT = OCI_SPOOL_ATTRVAL_WAIT,
472 NOWAIT = OCI_SPOOL_ATTRVAL_NOWAIT,
473 FORCEGET = OCI_SPOOL_ATTRVAL_FORCEGET
474 };
475
476 enum DestroyMode
477 {
478 DEFAULT = OCI_DEFAULT,
479 SPD_FORCE = OCI_SPD_FORCE
480 };
481
482 virtual ~StatelessConnectionPool() {}
483 virtual unsigned int getBusyConnections() const =0;
484 virtual unsigned int getOpenConnections() const =0;
485 virtual unsigned int getMinConnections() const =0;
486 virtual unsigned int getMaxConnections() const =0;
487 virtual unsigned int getIncrConnections() const =0;
488 virtual OCCI_STD_NAMESPACE::string getPoolName() const =0;
489 virtual unsigned int getTimeOut() const =0;
490 virtual void setBusyOption(BusyOption busyOption) =0;
491 virtual BusyOption getBusyOption() const =0;
492 virtual void setTimeOut(unsigned int connTimeOut =0) =0;
493 virtual void setPoolSize(unsigned int maxConn =1,
494 unsigned int minConn =0, unsigned int incrConn =1) =0;
495 virtual Connection* getConnection(
496 const OCCI_STD_NAMESPACE::string &tag ="") =0;
497 virtual Connection* getConnection(
498 const OCCI_STD_NAMESPACE::string &userName,
499 const OCCI_STD_NAMESPACE::string &password,
500 const OCCI_STD_NAMESPACE::string &tag = "") =0;
501 virtual Connection* getAnyTaggedConnection(
502 const OCCI_STD_NAMESPACE::string &tag = "") =0;
503 virtual Connection* getAnyTaggedConnection(
504 const OCCI_STD_NAMESPACE::string &userName,
505 const OCCI_STD_NAMESPACE::string &Password,
506 const OCCI_STD_NAMESPACE::string &tag = "") =0;
507 virtual Connection* getProxyConnection(
508 const OCCI_STD_NAMESPACE::string &name,
509 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
510 const OCCI_STD_NAMESPACE::string &tag = "",
511 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT) =0;
512 virtual Connection* getProxyConnection(
513 const OCCI_STD_NAMESPACE::string &name,
514 const OCCI_STD_NAMESPACE::string &tag = "" ,
515 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT) =0;
516 virtual Connection* getAnyTaggedProxyConnection(
517 const OCCI_STD_NAMESPACE::string &name,
518 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
519 const OCCI_STD_NAMESPACE::string &tag = "",
520 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT) =0;
521 virtual Connection* getAnyTaggedProxyConnection(
522 const OCCI_STD_NAMESPACE::string &name,
523 const OCCI_STD_NAMESPACE::string &tag="",
524 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT ) =0;
525 virtual void releaseConnection (Connection *connection,
526 const OCCI_STD_NAMESPACE::string &tag = "") =0;
527 virtual void terminateConnection (Connection *connection) =0;
528 virtual void setStmtCacheSize(unsigned int cacheSize) =0;
529 virtual unsigned int getStmtCacheSize() const =0;
530
531 virtual Connection* getConnection(const UString &tag)=0;
532 virtual Connection* getConnection(const UString &userName,
533 const UString &password,
534 const UString &tag)=0;
535 virtual Connection* getAnyTaggedConnection(const UString &tag)=0;
536 virtual Connection* getAnyTaggedConnection( const UString &userName,
537 const UString &Password, const UString &tag)=0 ;
538 virtual Connection* getProxyConnection(const UString &name,
539 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
540 const UString &tag,
541 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT)=0;
542 virtual Connection* getProxyConnection(const UString &name,
543 const UString &tag, Connection::ProxyType
544 proxyType = Connection::PROXY_DEFAULT)=0;
545 virtual Connection* getAnyTaggedProxyConnection(const UString &name,
546 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
547 const UString &tag,
548 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT)=0;
549 virtual Connection* getAnyTaggedProxyConnection(const UString &name,
550 const UString &tag,
551 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT )=0;
552 virtual void releaseConnection(Connection *connection,
553 const UString &tag)=0;
554
555
556 virtual Connection* getConnection(
557 const OCCI_STD_NAMESPACE::string &connectionClass,
558 const Connection::Purity purity,
559 const OCCI_STD_NAMESPACE::string &tag = "") =0;
560
561 virtual Connection* getConnection(
562 const OCCI_STD_NAMESPACE::string &userName,
563 const OCCI_STD_NAMESPACE::string &password,
564 const OCCI_STD_NAMESPACE::string &connectionClass,
565 const Connection::Purity purity,
566 const OCCI_STD_NAMESPACE::string &tag = "") =0;
567
568 virtual Connection* getAnyTaggedConnection(
569 const OCCI_STD_NAMESPACE::string &connectionClass,
570 const Connection::Purity purity,
571 const OCCI_STD_NAMESPACE::string &tag = "") =0;
572
573 virtual Connection* getAnyTaggedConnection(
574 const OCCI_STD_NAMESPACE::string &userName,
575 const OCCI_STD_NAMESPACE::string &Password,
576 const OCCI_STD_NAMESPACE::string &connectionClass,
577 const Connection::Purity purity,
578 const OCCI_STD_NAMESPACE::string &tag = "")= 0;
579
580 virtual Connection* getProxyConnection(
581 const OCCI_STD_NAMESPACE::string &name,
582 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
583 const OCCI_STD_NAMESPACE::string &connectionClass,
584 const Connection::Purity purity,
585 const OCCI_STD_NAMESPACE::string &tag = "",
586 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT) = 0;
587
588 virtual Connection* getProxyConnection(
589 const OCCI_STD_NAMESPACE::string &name,
590 const OCCI_STD_NAMESPACE::string &connectionClass,
591 const Connection::Purity purity,
592 const OCCI_STD_NAMESPACE::string &tag = "",
593 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT) = 0;
594
595 virtual Connection* getAnyTaggedProxyConnection(
596 const OCCI_STD_NAMESPACE::string &name,
597 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
598 const OCCI_STD_NAMESPACE::string &connectionClass,
599 const Connection::Purity purity,
600 const OCCI_STD_NAMESPACE::string &tag = "",
601 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT) = 0;
602
603
604 virtual Connection* getAnyTaggedProxyConnection(
605 const OCCI_STD_NAMESPACE::string &name,
606 const OCCI_STD_NAMESPACE::string &connectionClass,
607 const Connection::Purity purity,
608 const OCCI_STD_NAMESPACE::string &tag = "",
609 Connection::ProxyType proxyType = Connection::PROXY_DEFAULT) = 0;
610
611
612 virtual Connection* getConnection(
613 const UString &connectionClass,
614 const Connection::Purity purity,
615 const UString &tag) = 0;
616
617
618
619 virtual Connection* getConnection(const UString &userName,
620 const UString &password,
621 const UString &connectionClass,
622 const Connection::Purity purity,
623 const UString &tag) = 0;
624
625 virtual Connection* getAnyTaggedConnection(
626 const UString &connectionClass,
627 const Connection::Purity purity,
628 const UString &tag) =0;
629
630
631
632 virtual Connection* getAnyTaggedConnection( const UString &userName,
633 const UString &Password,
634 const UString &connectionClass,
635 const Connection::Purity purity,
636 const UString &tag) =0;
637
638 virtual Connection* getProxyConnection(const UString &name,
639 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
640 const UString &connectionClass,
641 const Connection::Purity purity,
642 const UString &tag, Connection::ProxyType proxyType) =0;
643
644 virtual Connection* getProxyConnection(const UString &name,
645 const UString &connectionClass,
646 const Connection::Purity purity,
647 const UString &tag, Connection::ProxyType proxyType) = 0;
648
649
650 virtual Connection* getAnyTaggedProxyConnection(const UString &name,
651 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
652 const UString &connectionClass,
653 const Connection::Purity purity,
654 const UString &tag,
655 Connection::ProxyType proxyType) = 0;
656
657 virtual Connection* getAnyTaggedProxyConnection(const UString &name,
658 const UString &connectionClass,
659 const Connection::Purity purity,
660 const UString &tag,
661 Connection::ProxyType proxyType ) =0;
662
663};
664
665
666class ConnectionPool
667{
668 public :
669
670 virtual ~ConnectionPool() {}
671 virtual unsigned int getBusyConnections() const
672 =0;
673 virtual unsigned int getOpenConnections() const
674 =0;
675 virtual unsigned int getMinConnections() const
676 =0;
677 virtual unsigned int getMaxConnections() const
678 =0;
679 virtual unsigned int getIncrConnections() const
680 =0;
681 virtual OCCI_STD_NAMESPACE::string getPoolName() const
682 =0;
683 virtual unsigned int getTimeOut() const
684 =0;
685 virtual void setErrorOnBusy()
686 =0;
687 virtual void setTimeOut(unsigned int connTimeOut =0)
688 =0;
689 virtual void setPoolSize(unsigned int minConn =0,
690 unsigned int maxConn =1, unsigned int incrConn =1)
691 =0;
692 virtual Connection* createConnection(
693 const OCCI_STD_NAMESPACE::string &userName,
694 const OCCI_STD_NAMESPACE::string &password) =0;
695
696 virtual Connection* createProxyConnection(
697 const OCCI_STD_NAMESPACE::string &name,
698 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
699 Connection::ProxyType proxyType =
700 Connection::PROXY_DEFAULT) =0;
701
702 virtual Connection* createProxyConnection(
703 const OCCI_STD_NAMESPACE::string &name,
704 Connection::ProxyType proxyType =
705 Connection::PROXY_DEFAULT) =0;
706
707 virtual void terminateConnection
708 (Connection *connection) =0;
709
710 //new interfaces
711
712 virtual Connection* createConnection(
713 const UString &userName,
714 const UString &password) =0;
715
716 virtual Connection* createProxyConnection(const UString &name,
717 OCCI_STD_NAMESPACE::string roles[], unsigned int numRoles,
718 Connection::ProxyType proxyType =
719 Connection::PROXY_DEFAULT) =0;
720
721 virtual Connection* createProxyConnection(const UString &name,
722 Connection::ProxyType proxyType =
723 Connection::PROXY_DEFAULT) =0;
724
725 virtual void setStmtCacheSize(unsigned int cacheSize) =0;
726 virtual unsigned int getStmtCacheSize() const =0;
727
728 virtual UString getPoolNameUString() const
729 =0;
730};
731
732class Environment
733{
734 public:
735 // class constants
736
737 enum Mode
738 {
739 DEFAULT = OCI_DEFAULT,
740 OBJECT = OCI_OBJECT,
741 SHARED = OCI_SHARED,
742 NO_USERCALLBACKS = OCI_NO_UCB,
743 THREADED_MUTEXED = OCI_THREADED,
744 THREADED_UNMUTEXED = OCI_THREADED | OCI_NO_MUTEX,
745 EVENTS = OCI_EVENTS,
746 USE_LDAP = OCI_USE_LDAP
747 };
748
749 virtual ~Environment(){}
750
751 // public methods
752
753 static Environment * createEnvironment(
754 Mode mode = DEFAULT,
755 void *ctxp = 0,
756 void *(*malocfp)(void *ctxp, size_t size) = 0,
757 void *(*ralocfp)(void *ctxp, void *memptr,
758 size_t newsize) = 0,
759 void (*mfreefp)(void *ctxp, void *memptr) = 0);
760
761 static Environment * createEnvironment(
762 const OCCI_STD_NAMESPACE::string &charset,
763 const OCCI_STD_NAMESPACE::string &ncharset,
764 Mode mode = DEFAULT,
765 void *ctxp = 0,
766 void *(*malocfp)(void *ctxp, size_t size) = 0,
767 void *(*ralocfp)(void *ctxp, void *memptr,
768 size_t newsize) = 0,
769 void (*mfreefp)(void *ctxp, void *memptr) = 0);
770
771 static void terminateEnvironment(Environment *env);
772
773 static Environment* getXAEnvironment(const
774 OCCI_STD_NAMESPACE::string& dbname);
775
776 static void releaseXAEnvironment(Environment *env);
777
778 static void getClientVersion( int &majorVersion, int &minorVersion,
779 int &updateNum, int &patchNum,
780 int &portUpdateNum );
781
782
783 virtual Connection * createConnection(
784 const OCCI_STD_NAMESPACE::string &userName,
785 const OCCI_STD_NAMESPACE::string &password,
786 const OCCI_STD_NAMESPACE::string &connectString = "") = 0;
787
788 virtual void terminateConnection(Connection *connection) = 0;
789
790 virtual ConnectionPool* createConnectionPool(
791 const OCCI_STD_NAMESPACE::string &poolUserName,
792 const OCCI_STD_NAMESPACE::string &poolPassword,
793 const OCCI_STD_NAMESPACE::string &connectString ="",
794 unsigned int minConn =0,
795 unsigned int maxConn =1, unsigned int incrConn =1) = 0;
796
797 virtual void terminateConnectionPool(ConnectionPool *poolp) = 0;
798
799 virtual unsigned int getCurrentHeapSize() const = 0;
800
801 virtual OCIEnv * getOCIEnvironment() const = 0;
802
803 virtual Map *getMap() const = 0;
804
805 virtual void setCacheMaxSize(unsigned int maxSize) = 0;
806
807 virtual unsigned int getCacheMaxSize() const = 0;
808
809 virtual void setCacheOptSize(unsigned int OptSize) = 0;
810
811 virtual unsigned int getCacheOptSize() const = 0;
812
813
814 //new interfaces
815
816 virtual Connection * createConnection(const UString &userName,
817 const UString &password, const UString &connectString) = 0;
818
819 virtual ConnectionPool* createConnectionPool(
820 const UString &poolUserName,
821 const UString &poolPassword, const UString &connectString,
822 unsigned int minConn =0,
823 unsigned int maxConn =1, unsigned int incrConn =1) = 0;
824
825 virtual Connection* getXAConnection(const
826 OCCI_STD_NAMESPACE::string& dbname) = 0;
827
828 virtual void releaseXAConnection(Connection* conn) =0;
829
830 virtual StatelessConnectionPool* createStatelessConnectionPool(
831 const OCCI_STD_NAMESPACE::string &poolUserName,
832 const OCCI_STD_NAMESPACE::string &poolPassword,
833 const OCCI_STD_NAMESPACE::string &connectString = "",
834 unsigned int maxConn = 1, unsigned int minConn = 0,
835 unsigned int incrConn = 1,
836 StatelessConnectionPool::PoolType pType
837 = StatelessConnectionPool::HETEROGENEOUS) = 0;
838
839 virtual StatelessConnectionPool* createStatelessConnectionPool(
840 const UString &poolUserName,
841 const UString &poolPassword,
842 const UString &connectString,
843 unsigned int maxConn = 1, unsigned int minConn = 0,
844 unsigned int incrConn = 1,
845 StatelessConnectionPool::PoolType pType
846 = StatelessConnectionPool::HETEROGENEOUS) = 0;
847
848 virtual void terminateStatelessConnectionPool(StatelessConnectionPool *poolp,
849 StatelessConnectionPool::DestroyMode mode = StatelessConnectionPool::DEFAULT)
850 = 0;
851 virtual void setLDAPAuthentication(unsigned int mode) =0;
852
853 virtual unsigned int getLDAPAuthentication() const =0;
854
855 virtual void setLDAPLoginNameAndPassword(
856 const OCCI_STD_NAMESPACE::string &login,
857 const OCCI_STD_NAMESPACE::string &passwd) =0;
858
859 virtual void setLDAPAdminContext(const OCCI_STD_NAMESPACE::string &ctx)=0;
860
861 virtual OCCI_STD_NAMESPACE::string getLDAPAdminContext() const =0;
862
863 virtual void setLDAPHostAndPort(const OCCI_STD_NAMESPACE::string &host,
864 unsigned int port) =0;
865
866 virtual OCCI_STD_NAMESPACE::string getLDAPHost() const =0;
867
868 virtual unsigned int getLDAPPort() const =0;
869
870 virtual void registerSubscriptions(
871 const OCCI_STD_NAMESPACE::vector<aq::Subscription>& sub) =0;
872
873 virtual void unregisterSubscription(const aq::Subscription& sub) =0;
874
875 virtual void enableSubscription(const aq::Subscription& sub) =0;
876
877 virtual void disableSubscription(const aq::Subscription& sub) =0;
878
879 virtual bool getCacheSortedFlush() const = 0;
880
881 virtual void setCacheSortedFlush(bool flag) = 0;
882
883 virtual Connection * createConnection(
884 const OCCI_STD_NAMESPACE::string &userName,
885 const OCCI_STD_NAMESPACE::string &password,
886 const OCCI_STD_NAMESPACE::string &connectString,
887 const OCCI_STD_NAMESPACE::string &connectionClass,
888 const Connection::Purity purity) = 0;
889
890 virtual Connection * createConnection(const UString &userName,
891 const UString &password, const UString &connectString,
892 const UString &connectionclass,
893 const Connection::Purity purity) =0;
894
895 private:
896
897};
898
899
900
901class Map
902{
903 public:
904
905 virtual ~Map(){}
906 virtual void put(const OCCI_STD_NAMESPACE::string&, void *(*)(void *),
907 void (*)(void *, void *)) = 0;
908 virtual void getReadSQL(
909 void *, unsigned int, void *, unsigned int, void **) const = 0;
910 virtual void getWriteSQL(
911 void *, unsigned int, void *, unsigned int, void **) const = 0;
912 virtual void put(const OCCI_STD_NAMESPACE::string&,
913 const OCCI_STD_NAMESPACE::string&, void *(*)(void *),
914 void (*)(void *, void *)) = 0;
915 virtual void putUTF16(const OCCI_STD_NAMESPACE::string&,
916 const OCCI_STD_NAMESPACE::string&, void *(*)(void *),
917 void (*)(void *, void *)) = 0;
918
919 private:
920};
921
922
923
924class SQLException : public OCCI_STD_NAMESPACE::exception
925{
926 public:
927
928 virtual int getErrorCode() const;
929
930 virtual OCCI_STD_NAMESPACE::string getMessage() const;
931
932 const char *what() const throw();
933
934 virtual void setErrorCtx(void *ctx);
935
936 SQLException();
937
938 SQLException(const SQLException &e);
939
940 void operator=(const SQLException &other);
941
942 virtual ~SQLException() throw();
943
944 virtual int getXAErrorCode(const OCCI_STD_NAMESPACE::string& dbname) const;
945
946 virtual UString getUStringMessage() const;
947
948 virtual OCCI_STD_NAMESPACE::string getNLSMessage(Environment *env) const;
949
950 virtual UString getNLSUStringMessage(Environment *env) const;
951
952 protected:
953
954 Ptr<SQLExceptionImpl> ptr_;
955 SQLException(SQLExceptionImpl *ptr);
956
957 friend SQLException SQLExceptionCreate(int errorCode);
958 friend SQLException SQLExceptionCreate(void *handle,
959 int handleType);
960 friend class BatchSQLException;
961};
962
963class BatchSQLException : public SQLException
964{
965 public:
966 virtual ~BatchSQLException() throw();
967
968 unsigned int getFailedRowCount() const;
969 unsigned int getRowNum( unsigned int index ) const;
970 SQLException getException ( unsigned int index ) const;
971
972 private:
973 BatchSQLException();
974
975 BatchSQLException(SQLExceptionImpl *ptr);
976 friend BatchSQLException BatchSQLExceptionCreate(void *handle);
977};
978
979class Statement
980{
981 public:
982 // class constants
983
984 virtual ~Statement() {}
985
986 enum Status
987 {
988 UNPREPARED,
989 PREPARED,
990 RESULT_SET_AVAILABLE,
991 UPDATE_COUNT_AVAILABLE,
992 NEEDS_STREAM_DATA,
993 STREAM_DATA_AVAILABLE
994 };
995
996 // common methods
997
998 virtual void setSQL(const OCCI_STD_NAMESPACE::string &sql) = 0;
999
1000 virtual OCCI_STD_NAMESPACE::string getSQL() const = 0;
1001
1002 virtual Status execute(const OCCI_STD_NAMESPACE::string &sql = "") = 0;
1003
1004 virtual ResultSet * getResultSet() = 0;
1005
1006 virtual unsigned int getUpdateCount() const = 0;
1007
1008 virtual ResultSet * executeQuery(
1009 const OCCI_STD_NAMESPACE::string &sql = "") = 0;
1010
1011 virtual unsigned int executeUpdate(
1012 const OCCI_STD_NAMESPACE::string &sql = "") = 0;
1013
1014 virtual Status status() const = 0;
1015
1016 virtual void closeResultSet(ResultSet *resultSet) = 0;
1017
1018 virtual void setPrefetchRowCount(unsigned int rowCount) = 0;
1019
1020 virtual void setPrefetchMemorySize(unsigned int bytes) = 0;
1021
1022 virtual void setAutoCommit(bool autoCommit) = 0;
1023
1024 virtual bool getAutoCommit() const = 0;
1025
1026 virtual OCIStmt * getOCIStatement() const = 0;
1027
1028
1029 // methods for prepared statements with IN
1030 // parameters
1031
1032 virtual void setMaxParamSize(unsigned int paramIndex,unsigned int maxSize)=0;
1033
1034 virtual unsigned int getMaxParamSize(unsigned int paramIndex) const = 0;
1035
1036 virtual void setNull(unsigned int paramIndex, Type type) = 0;
1037
1038 virtual void setInt(unsigned int paramIndex, int x) = 0;
1039
1040 virtual void setUInt(unsigned int paramIndex, unsigned int x) = 0;
1041
1042 virtual void setFloat(unsigned int paramIndex, float x) = 0;
1043
1044 virtual void setDouble(unsigned int paramIndex, double x) = 0;
1045
1046 virtual void setNumber(unsigned int paramIndex, const Number &x) = 0;
1047
1048 virtual void setString(unsigned int paramIndex,
1049 const OCCI_STD_NAMESPACE::string &x) = 0;
1050
1051 virtual void setBytes(unsigned int paramIndex, const Bytes &x) = 0;
1052
1053 virtual void setDate(unsigned int paramIndex, const Date &x) = 0;
1054
1055 virtual void setTimestamp(unsigned int paramIndex, const Timestamp &x) = 0;
1056
1057 virtual void setBlob(unsigned int paramIndex, const Blob &x) = 0;
1058
1059 virtual void setClob(unsigned int paramIndex, const Clob &x) = 0;
1060
1061 virtual void setBfile(unsigned int paramIndex, const Bfile &x) = 0;
1062
1063 virtual void setIntervalYM(unsigned int paramIndex, const IntervalYM &x) = 0;
1064
1065 virtual void setIntervalDS(unsigned int paramIndex, const IntervalDS &x) = 0;
1066
1067 virtual void setRowid(unsigned int paramIndex, const Bytes &x) = 0;
1068
1069 virtual void setRef(unsigned int paramIndex, const RefAny &x) = 0;
1070
1071 virtual void setObject(unsigned int paramIndex, PObject * x) = 0;
1072
1073 virtual void setDataBuffer(unsigned int paramIndex, void *buffer,
1074 Type type,
1075 sb4 size, ub2 *length, sb2 *ind = NULL,
1076 ub2 *rc = NULL) = 0;
1077
1078 virtual void setDataBufferArray(unsigned int paramIndex, void *buffer,
1079 Type type,
1080 ub4 arraySize, ub4 *arrayLength,
1081 sb4 elementSize,
1082 ub2 *elementLength, sb2 *ind = NULL,
1083 ub2 *rc = NULL) = 0;
1084
1085 virtual void setCharSet(unsigned int paramIndex,
1086 const OCCI_STD_NAMESPACE::string & charSet) = 0;
1087
1088 virtual OCCI_STD_NAMESPACE::string getCharSet(unsigned int paramIndex)
1089 const = 0;
1090
1091 virtual void setDatabaseNCHARParam(
1092 unsigned int paramIndex, bool isNCHAR) = 0;
1093
1094 virtual bool getDatabaseNCHARParam(unsigned int paramIndex) const = 0;
1095
1096 virtual void closeStream(Stream *stream) =0;
1097
1098 virtual Stream * getStream(unsigned int paramIndex) = 0;
1099
1100 virtual unsigned int getCurrentStreamParam() const = 0;
1101
1102 virtual unsigned int getCurrentStreamIteration() const = 0;
1103
1104 virtual void setBinaryStreamMode(unsigned int colIndex,
1105 unsigned int size) =0;
1106
1107 virtual void setCharacterStreamMode(unsigned int colIndex,
1108 unsigned int size) =0;
1109
1110 virtual void setMaxIterations(unsigned int maxIterations) = 0;
1111
1112 virtual unsigned int getMaxIterations() const = 0;
1113
1114 virtual void addIteration() = 0;
1115
1116 virtual unsigned int getCurrentIteration() const = 0;
1117
1118 virtual Status executeArrayUpdate(unsigned int arrayLength) = 0;
1119
1120
1121 // methods for Callable Statements
1122
1123 virtual void registerOutParam(unsigned int paramIndex, Type type,
1124 unsigned int maxSize=0, const OCCI_STD_NAMESPACE::string &sqltype="") = 0;
1125
1126 virtual bool isNull(unsigned int paramIndex) const = 0;
1127
1128 virtual bool isTruncated(unsigned int paramIndex) const
1129 =0;
1130
1131
1132 virtual void setErrorOnNull(unsigned int paramIndex,
1133 bool causeException) = 0;
1134
1135 virtual void setErrorOnTruncate(unsigned int paramIndex,
1136 bool causeException) = 0;
1137
1138 virtual int preTruncationLength(unsigned int paramIndex) const
1139 =0;
1140
1141
1142 virtual int getInt(unsigned int paramIndex) = 0;
1143
1144 virtual unsigned int getUInt(unsigned int paramIndex) = 0;
1145
1146 virtual float getFloat(unsigned int paramIndex) = 0;
1147
1148 virtual double getDouble(unsigned int paramIndex) = 0;
1149
1150 virtual Number getNumber(unsigned int paramIndex) = 0;
1151
1152 virtual OCCI_STD_NAMESPACE::string getString(unsigned int paramIndex) = 0;
1153
1154 virtual Bytes getBytes(unsigned int paramIndex) = 0;
1155
1156 virtual Date getDate(unsigned int paramIndex) = 0;
1157
1158 virtual Timestamp getTimestamp(unsigned int paramIndex) = 0;
1159
1160 virtual Bytes getRowid(unsigned int paramIndex) = 0;
1161
1162 virtual PObject * getObject(unsigned int paramIndex) = 0;
1163
1164 virtual Blob getBlob(unsigned int paramIndex) = 0;
1165
1166 virtual Clob getClob(unsigned int paramIndex) = 0;
1167
1168 virtual Bfile getBfile(unsigned int paramIndex) = 0;
1169
1170 virtual IntervalYM getIntervalYM(unsigned int paramIndex) = 0;
1171
1172 virtual IntervalDS getIntervalDS(unsigned int paramIndex) = 0;
1173
1174 virtual RefAny getRef(unsigned int paramIndex) = 0;
1175
1176 virtual ResultSet * getCursor(unsigned int paramIndex) = 0;
1177
1178 virtual Connection* getConnection() const =0;
1179
1180 //new interfaces
1181
1182 virtual void setRef(unsigned int paramIndex, const RefAny &x,
1183 const OCCI_STD_NAMESPACE::string &typName,
1184 const OCCI_STD_NAMESPACE::string &schName = "") = 0;
1185
1186 virtual void setSQLUString(const UString &sql) = 0;
1187
1188 virtual UString getSQLUString() const = 0;
1189
1190 virtual Status execute(const UString &sql) = 0;
1191
1192 virtual ResultSet * executeQuery(
1193 const UString &sql) = 0;
1194
1195 virtual unsigned int executeUpdate(
1196 const UString &sql) = 0;
1197
1198 virtual void setBFloat(unsigned int paramIndex, const BFloat &fval) = 0;
1199
1200 virtual void setBDouble(unsigned int paramIndex, const BDouble &dval) = 0;
1201
1202 virtual void setUString(unsigned int paramIndex,
1203 const UString &x) = 0;
1204
1205 virtual void setCharSetUString(unsigned int paramIndex,
1206 const UString & charSet) = 0;
1207
1208 virtual UString getCharSetUString(unsigned int paramIndex)
1209 const = 0;
1210
1211 virtual void registerOutParam(unsigned int paramIndex, Type type,
1212 unsigned int maxSize, const OCCI_STD_NAMESPACE::string &typName,
1213 const OCCI_STD_NAMESPACE::string &schName) = 0;
1214
1215 virtual void registerOutParam(unsigned int paramIndex, Type type,
1216 unsigned int maxSize, const UString &typName,
1217 const UString &schName) = 0;
1218
1219 virtual BFloat getBFloat(unsigned int paramIndex) = 0;
1220
1221 virtual BDouble getBDouble(unsigned int paramIndex) = 0;
1222
1223 virtual UString getUString(unsigned int paramIndex) = 0;
1224
1225 virtual void disableCaching() =0;
1226
1227 virtual void setRef(unsigned int paramIndex, const RefAny &x,
1228 const UString &typName,
1229 const UString &schName) = 0;
1230
1231 virtual void setBinaryStreamMode(unsigned int colIndex,
1232 unsigned int size, bool INArg) =0;
1233
1234 virtual void setCharacterStreamMode(unsigned int colIndex,
1235 unsigned int size, bool INArg) =0;
1236
1237 virtual void setNull(unsigned int paramIndex, Type type,
1238 const OCCI_STD_NAMESPACE::string &typeName,
1239 const OCCI_STD_NAMESPACE::string &schemaName = "") = 0;
1240
1241 virtual void setNull(unsigned int paramIndex, Type type,
1242 UString &typeName, UString &schemaName) = 0;
1243
1244 virtual void setBatchErrorMode( bool batchErrorMode ) =0;
1245
1246 virtual bool getBatchErrorMode( ) const =0;
1247
1248};
1249
1250
1251
1252class ResultSet
1253{
1254 public:
1255 // class constants
1256
1257 enum Status
1258 {
1259 END_OF_FETCH = 0,
1260 DATA_AVAILABLE,
1261 STREAM_DATA_AVAILABLE
1262 };
1263 virtual ~ResultSet(){}
1264
1265 // public methods
1266
1267 virtual Status next(unsigned int numRows = 1) = 0;
1268
1269 virtual Status status() const = 0;
1270
1271 virtual unsigned int getNumArrayRows() const = 0;
1272
1273 virtual void cancel() = 0;
1274
1275 virtual void setMaxColumnSize(unsigned int colIndex, unsigned int max) = 0;
1276
1277 virtual unsigned int getMaxColumnSize(unsigned int colIndex) const = 0;
1278
1279 virtual bool isNull(unsigned int colIndex) const = 0;
1280
1281 virtual bool isTruncated(unsigned int paramIndex) const
1282 =0;
1283
1284 virtual void setErrorOnNull(unsigned int colIndex, bool causeException) = 0;
1285 virtual void setErrorOnTruncate(unsigned int paramIndex,
1286 bool causeException) =0;
1287
1288 virtual int preTruncationLength(unsigned int paramIndex) const
1289 =0;
1290
1291 virtual int getInt(unsigned int colIndex) = 0;
1292
1293 virtual unsigned int getUInt(unsigned int colIndex) = 0;
1294
1295 virtual float getFloat(unsigned int colIndex) = 0;
1296
1297 virtual double getDouble(unsigned int colIndex) = 0;
1298
1299 virtual Number getNumber(unsigned int colIndex) = 0;
1300
1301 virtual OCCI_STD_NAMESPACE::string getString(unsigned int colIndex) = 0;
1302
1303 virtual Bytes getBytes(unsigned int colIndex) = 0;
1304
1305 virtual Date getDate(unsigned int colIndex) = 0;
1306
1307 virtual Timestamp getTimestamp(unsigned int colIndex) = 0;
1308
1309 virtual Bytes getRowid(unsigned int colIndex) = 0;
1310
1311 virtual PObject * getObject(unsigned int colIndex) = 0;
1312
1313 virtual Blob getBlob(unsigned int colIndex) = 0;
1314
1315 virtual Clob getClob(unsigned int colIndex) =0;
1316
1317 virtual Bfile getBfile(unsigned int colIndex) = 0;
1318
1319 virtual IntervalYM getIntervalYM(unsigned int colIndex) =0;
1320
1321 virtual IntervalDS getIntervalDS(unsigned int colIndex) =0;
1322
1323 virtual RefAny getRef(unsigned int colIndex) = 0;
1324
1325 virtual Bytes getRowPosition() const = 0;
1326
1327 virtual ResultSet * getCursor(unsigned int colIndex) = 0;
1328
1329 virtual void setDataBuffer(unsigned int colIndex, void *buffer, Type type,
1330 sb4 size = 0, ub2 *length = NULL,
1331 sb2 *ind = NULL, ub2 *rc = NULL) = 0;
1332
1333 virtual void setCharSet(unsigned int colIndex,
1334 const OCCI_STD_NAMESPACE::string & charSet) = 0;
1335
1336 virtual OCCI_STD_NAMESPACE::string getCharSet(unsigned int colIndex)
1337 const = 0;
1338
1339 virtual void setBinaryStreamMode(unsigned int colIndex, unsigned int size)
1340 = 0;
1341
1342 virtual void setCharacterStreamMode(unsigned int colIndex, unsigned int size)
1343 = 0;
1344
1345 virtual void setDatabaseNCHARParam(unsigned int paramIndex,
1346 bool isNCHAR) = 0;
1347
1348 virtual bool getDatabaseNCHARParam(unsigned int paramIndex) const = 0;
1349
1350 virtual Stream * getStream(unsigned int colIndex) = 0;
1351
1352 virtual void closeStream(Stream *stream) =0;
1353
1354 virtual unsigned int getCurrentStreamColumn() const= 0;
1355
1356 virtual unsigned int getCurrentStreamRow() const= 0;
1357
1358 virtual OCCI_STD_NAMESPACE::vector<MetaData> getColumnListMetaData() const
1359 = 0;
1360
1361 virtual Statement* getStatement() const=0;
1362
1363 //new interfaces
1364
1365 virtual BFloat getBFloat(unsigned int colIndex) = 0;
1366
1367 virtual BDouble getBDouble(unsigned int colIndex) = 0;
1368
1369 virtual UString getUString(unsigned int colIndex) = 0;
1370
1371 virtual void setCharSetUString(unsigned int colIndex,
1372 const UString & charSet) = 0;
1373
1374 virtual UString getCharSetUString(unsigned int colIndex)
1375 const = 0;
1376
1377 virtual void setPrefetchRowCount(unsigned int rowCount) = 0;
1378
1379 virtual void setPrefetchMemorySize(unsigned int bytes) = 0;
1380};
1381
1382
1383class Stream
1384{
1385 public :
1386
1387 enum Status {READY_FOR_READ, READY_FOR_WRITE, INACTIVE};
1388
1389 virtual ~Stream(){}
1390 virtual int readBuffer(char *buffer, unsigned int size)
1391 =0;
1392 virtual int readLastBuffer(char *buffer, unsigned int size)
1393 =0;
1394 virtual void writeBuffer(char *buffer, unsigned int size)
1395 =0;
1396 virtual void writeLastBuffer(char *buffer, unsigned int size)
1397 =0;
1398 virtual Status status() const =0;
1399
1400};
1401
1402/*---------------------------------------------------------------------------
1403 PROTOTYPES USED BY FUNCTION TEMPLATES
1404 -------------------------------------------------------------------------*/
1405 void getVectorOfPObjects( ResultSet *rs, unsigned int index,
1406 OCCI_STD_NAMESPACE::vector<PObject *> &vect) ;
1407 void getVectorOfOCIRefs(ResultSet *rs, unsigned int index,
1408 OCCI_STD_NAMESPACE::vector<void *> &vect) ;
1409 void getVectorOfPObjects( Statement *rs, unsigned int index,
1410 OCCI_STD_NAMESPACE::vector<PObject *> &vect) ;
1411 void getVectorOfOCIRefs(Statement *rs, unsigned int index,
1412 OCCI_STD_NAMESPACE::vector<void *> &vect) ;
1413 void setVectorOfPObjects( Statement *stmt, unsigned int paramIndex,
1414 const OCCI_STD_NAMESPACE::vector<PObject *> &vect,
1415 const OCCI_STD_NAMESPACE::string &sqltype) ;
1416 void setVectorOfPObjects( Statement *stmt, unsigned int paramIndex,
1417 const OCCI_STD_NAMESPACE::vector<PObject *> &vect,
1418 const OCCI_STD_NAMESPACE::string &schemaName,
1419 const OCCI_STD_NAMESPACE::string &typeName) ;
1420 void setVectorOfPObjects( Statement *stmt, unsigned int paramIndex,
1421 const OCCI_STD_NAMESPACE::vector<PObject *> &vect,
1422 const UString &schemaName,
1423 const UString &typeName) ;
1424 void setVectorOfOCIRefs(Statement *stmt, unsigned int paramIndex,
1425 const OCCI_STD_NAMESPACE::vector<void *> &vect,
1426 const OCCI_STD_NAMESPACE::vector<OCIInd> &vecind,
1427 const OCCI_STD_NAMESPACE::string &sqltype) ;
1428 void setVectorOfOCIRefs(Statement *stmt, unsigned int paramIndex,
1429 const OCCI_STD_NAMESPACE::vector<void *> &vect,
1430 const OCCI_STD_NAMESPACE::vector<OCIInd> &vecind,
1431 const OCCI_STD_NAMESPACE::string &schemaName,
1432 const OCCI_STD_NAMESPACE::string &typeName) ;
1433 void setVectorOfOCIRefs(Statement *stmt, unsigned int paramIndex,
1434 const OCCI_STD_NAMESPACE::vector<void *> &vect,
1435 const OCCI_STD_NAMESPACE::vector<OCIInd> &vecind,
1436 const UString &schemaName,
1437 const UString &typeName) ;
1438 void pinVectorOfOCIRefs(const Connection *conn,
1439 OCCI_STD_NAMESPACE::vector<void *> & vecRef,
1440 OCCI_STD_NAMESPACE::vector<void *> & vecCor,
1441 OCCI_STD_NAMESPACE::vector<PObject *> &vecPObj,LockOptions &lockOpt );
1442
1443
1444/*---------------------------------------------------------------------------
1445 EXPORT FUNCTIONS
1446 ---------------------------------------------------------------------------*/
1447
1448/*------------------------ getVector for objects ---------------------------*/
1449/*
1450 NAME
1451 getVector - overloaded function. Retrieves the attribute in the current
1452position as a vector of objects
1453
1454 PARAMETERS
1455 rs - ResultSet
1456 vect- reference to vector of objects(OUT parameter).
1457
1458 DESCRIPTION
1459 Retrieves the column in the specified position as a vector of RefAny.
1460 The attribute at the current position should be a collection type (varray or
1461 nested table). The SQL type of the elements in the collection should be
1462 compatible with objects.
1463
1464 RETURNS
1465 nothing
1466
1467 NOTES
1468 compatible SQL types : NTY
1469
1470 will call getVector(..., vector<PObject*>)
1471*/
1472#if defined(WIN32COMMON) || defined(__MVS__)
1473// and other platforms that do not support
1474// partial function template specialization
1475
1476template <class T>
1477void getVector( ResultSet *rs, unsigned int index,OCCI_STD_NAMESPACE::vector<T>
1478& vect)
1479{
1480 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1481 getVectorOfPObjects(rs, index, vec_pobj);
1482
1483 vect.clear();
1484 unsigned int size = vec_pobj.size();
1485 vect.reserve( size );
1486 for ( unsigned int i=0; i< size; i++)
1487 vect.push_back((T)vec_pobj[i]);
1488}
1489
1490#else
1491template <class T>
1492void getVector( ResultSet *rs, unsigned int index, OCCI_STD_NAMESPACE::vector<T
1493 *> &vect)
1494{
1495 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1496 getVectorOfPObjects(rs, index, vec_pobj);
1497
1498 vect.clear();
1499 unsigned int size = vec_pobj.size();
1500 vect.reserve( size );
1501 for (unsigned int i=0; i< size; i++)
1502 vect.push_back((T *)vec_pobj[i]);
1503}
1504#endif
1505
1506/*------------------------ getVector for objects ---------------------------*/
1507/*
1508 NAME
1509 getVector - overloaded function. Retrieves the attribute in the current
1510position as a vector of objects
1511
1512 PARAMETERS
1513 stmt - Statement
1514 vect- reference to vector of objects(OUT parameter).
1515
1516 DESCRIPTION
1517 Retrieves the column in the specified position as a vector of RefAny.
1518 The attribute at the current position should be a collection type (varray or
1519 nested table). The SQL type of the elements in the collection should be
1520 compatible with objects.
1521
1522 RETURNS
1523 nothing
1524
1525 NOTES
1526 compatible SQL types : NTY
1527
1528 will call getVector(..., vector<PObject*>)
1529*/
1530#if defined(WIN32COMMON) || defined(__MVS__)
1531// and other platforms that do not support
1532// partial function template specialization
1533
1534template <class T>
1535void getVector( Statement *stmt, unsigned int index,
1536OCCI_STD_NAMESPACE::vector<T> &vect)
1537{
1538 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1539 getVectorOfPObjects(stmt, index, vec_pobj);
1540 vect.clear();
1541 unsigned int size = vec_pobj.size();
1542 vect.reserve( size );
1543 for (unsigned int i=0; i< size; i++)
1544 vect.push_back((T)vec_pobj[i]);
1545}
1546#else
1547template <class T>
1548void getVector( Statement *stmt, unsigned int index,
1549OCCI_STD_NAMESPACE::vector<T *> &vect)
1550{
1551 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1552 getVectorOfPObjects(stmt, index, vec_pobj);
1553 vect.clear();
1554 unsigned int size = vec_pobj.size();
1555 vect.reserve( size );
1556 for (unsigned int i=0; i< size; i++)
1557 vect.push_back((T *)vec_pobj[i]);
1558}
1559#endif
1560
1561/*------------------------ getVector for Ref<T> ---------------------------*/
1562/*
1563 NAME
1564 getVector - overloaded function. Retrieves the attribute in the current
1565position as a vector of Ref<T>
1566
1567 PARAMETERS
1568 rs - ResultSet
1569 vect- reference to vector of Ref<T>(OUT parameter).
1570
1571 DESCRIPTION
1572 Retrieves the column in the specified position as a vector of Ref<T>.
1573 The attribute at the current position should be a collection type (varray or
1574 nested table). The SQL type of the elements in the collection should be
1575 compatible with Ref<T>.
1576
1577 RETURNS
1578 nothing
1579
1580 NOTES
1581 compatible SQL types : REF
1582*/
1583#if !defined(WIN32COMMON) && !defined(__MVS__)
1584template <class T>
1585void getVector( ResultSet *rs, unsigned int index,
1586 OCCI_STD_NAMESPACE::vector<Ref<T> > &vect)
1587{
1588 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1589 getVectorOfOCIRefs(rs, index, vec_ref);
1590
1591 const Connection *sess = rs->getStatement()->getConnection();
1592
1593 vect.clear();
1594 unsigned int size = vec_ref.size();
1595 vect.reserve( size );
1596 for (unsigned int i=0; i< size; i++)
1597 {
1598 if (vec_ref[i] == (OCIRef *)0)
1599 vect.push_back(Ref<T>()); // pushing a default-constructed Ref
1600 else
1601 vect.push_back(Ref<T>(sess, (OCIRef *)vec_ref[i], FALSE));
1602 }
1603}
1604#endif
1605
1606/*------------------------ setVector for PObject*---------------------------*/
1607/*
1608 NAME
1609 SetVector - overloaded function. Binds the attribute in the current
1610 position with a vector of objects.
1611
1612 PARAMETERS
1613 rs - ResultSet
1614 vect- reference to vector of objects(OUT parameter).
1615
1616 DESCRIPTION
1617 Binds the column in the specified position with a vector of signed int .
1618 The column at the current position should be a collection type (varray or
1619 nested table). The SQL type of the elements in the collection should be
1620 compatible with objects .
1621
1622 RETURNS
1623 nothing
1624
1625 NOTES
1626 compatible SQL types : SQLT_NTY
1627
1628 This will be calling setVector(..., vector<PObject*>,..)
1629
1630*/
1631#if defined(WIN32COMMON) || defined(__MVS__)
1632// and other platforms that do not support
1633// partial function template specialization
1634
1635template <class T>
1636void setVector( Statement *stmt, unsigned int index,
1637 const OCCI_STD_NAMESPACE::vector<T> &vect,
1638 const OCCI_STD_NAMESPACE::string &sqltype)
1639{
1640 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1641 unsigned int size = vect.size();
1642 vec_pobj.reserve( size );
1643
1644 for (unsigned int i = 0; i < size; i++)
1645 vec_pobj.push_back((PObject *)vect[i]);
1646
1647 setVectorOfPObjects(stmt, index, vec_pobj, sqltype);
1648}
1649
1650template <class T>
1651void setVector( Statement *stmt, unsigned int index, const OCCI_STD_NAMESPACE::
1652vector<T> &vect, const OCCI_STD_NAMESPACE::string &schemaName,
1653const OCCI_STD_NAMESPACE::string &typeName)
1654{
1655 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1656 unsigned int size = vect.size();
1657 vec_pobj.reserve( size );
1658
1659 for (unsigned int i = 0; i < size; i++)
1660 vec_pobj.push_back((PObject *)vect[i]);
1661
1662 setVectorOfPObjects(stmt, index, vec_pobj, schemaName, typeName);
1663}
1664
1665template <class T>
1666void setVector( Statement *stmt, unsigned int index, const OCCI_STD_NAMESPACE::
1667vector<T> &vect, const UString &schemaName,
1668const UString &typeName)
1669{
1670 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1671 unsigned int size = vect.size();
1672 vec_pobj.reserve( size );
1673
1674 for (unsigned int i = 0; i < size; i++)
1675 vec_pobj.push_back((PObject *)vect[i]);
1676
1677 setVectorOfPObjects(stmt, index, vec_pobj, schemaName, typeName);
1678}
1679#else
1680template <class T>
1681void setVector( Statement *stmt, unsigned int index, const OCCI_STD_NAMESPACE::
1682vector<T *> &vect, const OCCI_STD_NAMESPACE::string &sqltype)
1683{
1684 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1685 unsigned int size = vect.size();
1686 vec_pobj.reserve( size );
1687
1688 for (unsigned int i = 0; i < size; i++)
1689 vec_pobj.push_back((PObject *)vect[i]);
1690
1691 setVectorOfPObjects(stmt, index, vec_pobj, sqltype);
1692}
1693
1694template <class T>
1695void setVector( Statement *stmt, unsigned int index, const OCCI_STD_NAMESPACE::
1696vector<T *> &vect, const OCCI_STD_NAMESPACE::string &schemaName,
1697const OCCI_STD_NAMESPACE::string &typeName)
1698{
1699 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1700 unsigned int size = vect.size();
1701 vec_pobj.reserve( size );
1702
1703 for (unsigned int i = 0; i < size; i++)
1704 vec_pobj.push_back((PObject *)vect[i]);
1705
1706 setVectorOfPObjects(stmt, index, vec_pobj, schemaName, typeName);
1707}
1708
1709template <class T>
1710void setVector( Statement *stmt, unsigned int index, const OCCI_STD_NAMESPACE::
1711vector<T *> &vect, const UString &schemaName,
1712const UString &typeName)
1713{
1714 OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
1715 unsigned int size = vect.size();
1716 vec_pobj.reserve( size );
1717
1718 for (unsigned int i = 0; i < size; i++)
1719 vec_pobj.push_back((PObject *)vect[i]);
1720
1721 setVectorOfPObjects(stmt, index, vec_pobj, schemaName, typeName);
1722}
1723#endif
1724
1725/*------------------------ setVector for Ref<T>---------------------------*/
1726/*
1727 NAME
1728 setVector - overloaded function. Binds the attribute in the current
1729 position with a vector of Ref<T>.
1730
1731 PARAMETERS
1732 rs - ResultSet
1733 vect- reference to vector of REF
1734
1735 DESCRIPTION
1736 Binds the column in the specified position with a vector of signed int .
1737 The column at the current position should be a collection type (varray or
1738 nested table). The SQL type of the elements in the collection should be
1739 compatible with OCIRef* .
1740
1741 RETURNS
1742 nothing
1743
1744 NOTES
1745 compatible SQL types : REF
1746
1747 This will just call setVector(..., vector<OCIRef*>,..)
1748
1749
1750*/
1751#if !defined(WIN32COMMON) && !defined(__MVS__)
1752template <class T>
1753void setVector( Statement *stmt, unsigned int index,
1754 const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect,
1755 const OCCI_STD_NAMESPACE::string &sqltype)
1756{
1757 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1758 OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
1759 unsigned int size = vect.size();
1760 vec_ref.reserve( size );
1761 vec_ind.reserve( size );
1762
1763 for (unsigned int i = 0; i < size; i++)
1764 {
1765 vec_ref.push_back((void *)vect[i].getRef());
1766 vec_ind.push_back( vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
1767 }
1768
1769 setVectorOfOCIRefs(stmt, index, vec_ref, vec_ind, sqltype);
1770}
1771
1772template <class T>
1773void setVector( Statement *stmt, unsigned int index,
1774 const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect,
1775 const OCCI_STD_NAMESPACE::string &schemaName,
1776 const OCCI_STD_NAMESPACE::string &typeName)
1777{
1778 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1779 OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
1780 unsigned int size = vect.size();
1781 vec_ref.reserve( size );
1782 vec_ind.reserve( size );
1783
1784 for (unsigned int i = 0; i < size; i++)
1785 {
1786 vec_ref.push_back((void *)vect[i].getRef());
1787 vec_ind.push_back( vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
1788 }
1789
1790 setVectorOfOCIRefs(stmt, index, vec_ref, vec_ind, schemaName, typeName);
1791}
1792
1793template <class T>
1794void setVector( Statement *stmt, unsigned int index,
1795 const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect,
1796 const UString &schemaName,
1797 const UString &typeName)
1798{
1799 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1800 OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
1801 unsigned int size = vect.size();
1802 vec_ref.reserve( size );
1803 vec_ind.reserve( size );
1804
1805 for (unsigned int i = 0; i < size; i++)
1806 {
1807 vec_ref.push_back((void *)vect[i].getRef());
1808 vec_ind.push_back( vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
1809 }
1810
1811 setVectorOfOCIRefs(stmt, index, vec_ref, vec_ind, schemaName, typeName);
1812}
1813#endif
1814
1815/*------------------------ getVector for Ref<T> ---------------------------*/
1816/*
1817 NAME
1818 getVector - overloaded function. Retrieves the attribute in the current
1819position as a vector of Ref<T>
1820
1821 PARAMETERS
1822 stmt - Statement
1823 vect- reference to vector of Ref<T>(OUT parameter).
1824
1825 DESCRIPTION
1826 Retrieves the column in the specified position as a vector of Ref<T>.
1827 The attribute at the current position should be a collection type (varray or
1828 nested table). The SQL type of the elements in the collection should be
1829 compatible with Ref<T>.
1830
1831 RETURNS
1832 nothing
1833
1834 NOTES
1835 compatible SQL types : REF
1836*/
1837#if !defined(WIN32COMMON) && !defined(__MVS__)
1838template <class T>
1839void getVector( Statement *stmt, unsigned int index,
1840 OCCI_STD_NAMESPACE::vector<Ref<T> > &vect)
1841{
1842 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1843 getVectorOfOCIRefs(stmt, index, vec_ref);
1844
1845 const Connection *sess = stmt->getConnection();
1846
1847 vect.clear();
1848 unsigned int size = vec_ref.size();
1849 vect.reserve( size );
1850 for (unsigned int i=0; i< size; i++)
1851 {
1852 if (vec_ref[i] == (OCIRef *)0)
1853 vect.push_back(Ref <T>()); // pushing a default-constructed Ref
1854 else
1855 vect.push_back(Ref<T> (sess, (OCIRef *)vec_ref[i], FALSE));
1856 }
1857
1858}
1859#endif
1860
1861// Platform independent get/setVectorOfRefs method added
1862// get(set)Vector of Ref<T> and get(set)VectorOfRefs are identical
1863// in functionality.
1864
1865/*------------------------ getVectorOfRefs for Ref<T> ----------------------*/
1866/*
1867 NAME
1868 getVectorOfRefs - overloaded function. Retrieves the attribute in the
1869 current position as a vector of Ref<T>
1870
1871 PARAMETERS
1872 rs - ResultSet
1873 vect- reference to vector of Ref<T>(OUT parameter).
1874
1875 DESCRIPTION
1876 Retrieves the column in the specified position as a vector of Ref<T>.
1877 The attribute at the current position should be a collection type (varray or
1878 nested table). The SQL type of the elements in the collection should be
1879 compatible with Ref<T>.
1880
1881 RETURNS
1882 nothing
1883
1884 NOTES
1885 compatible SQL types : REF
1886*/
1887
1888template <class T>
1889void getVectorOfRefs( ResultSet *rs, unsigned int index,
1890OCCI_STD_NAMESPACE::vector<Ref<T> > &vect)
1891{
1892 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1893 getVectorOfOCIRefs(rs, index, vec_ref);
1894
1895 const Connection *sess = rs->getStatement()->getConnection();
1896
1897 vect.clear();
1898 unsigned int size = vec_ref.size();
1899 vect.reserve( size );
1900 for (unsigned int i=0; i< size; i++)
1901 {
1902 if (vec_ref[i] == (OCIRef *)0)
1903 vect.push_back(Ref<T>()); // pushing a default-constructed Ref
1904 else
1905 vect.push_back(Ref<T>(sess, (OCIRef *)vec_ref[i], FALSE));
1906 }
1907}
1908
1909/*------------------------ setVectorOfRefs for Ref<T>-----------------------*/
1910/*
1911 NAME
1912 setVectorOfRefs - overloaded function. Binds the attribute in the current
1913 position with a vector of Ref<T>.
1914
1915 PARAMETERS
1916 rs - ResultSet
1917 vect- reference to vector of REF
1918
1919 DESCRIPTION
1920 Binds the column in the specified position with a vector of signed int .
1921 The column at the current position should be a collection type (varray or
1922 nested table). The SQL type of the elements in the collection should be
1923 compatible with OCIRef* .
1924
1925 RETURNS
1926 nothing
1927
1928 NOTES
1929 compatible SQL types : REF
1930
1931 This will just call setVector(..., vector<OCIRef*>,..)
1932
1933
1934*/
1935
1936template <class T>
1937void setVectorOfRefs( Statement *stmt, unsigned int index,
1938const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect,
1939const OCCI_STD_NAMESPACE::string &sqltype)
1940{
1941 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1942 OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
1943 unsigned int size = vect.size();
1944 vec_ref.reserve( size );
1945 vec_ind.reserve( size );
1946
1947 for (unsigned int i = 0; i < size; i++)
1948 {
1949 vec_ref.push_back((void *)vect[i].getRef());
1950 vec_ind.push_back( vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
1951 }
1952
1953 setVectorOfOCIRefs(stmt, index, vec_ref, vec_ind, sqltype);
1954}
1955
1956template <class T>
1957void setVectorOfRefs( Statement *stmt, unsigned int index,
1958const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect,
1959const OCCI_STD_NAMESPACE::string &schemaName,
1960const OCCI_STD_NAMESPACE::string &typeName)
1961{
1962 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1963 OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
1964 unsigned int size = vect.size();
1965 vec_ref.reserve( size );
1966 vec_ind.reserve( size );
1967
1968 for (unsigned int i = 0; i < size; i++)
1969 {
1970 vec_ref.push_back((void *)vect[i].getRef());
1971 vec_ind.push_back( vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
1972 }
1973
1974 setVectorOfOCIRefs(stmt, index, vec_ref, vec_ind, schemaName, typeName);
1975}
1976
1977template <class T>
1978void setVectorOfRefs( Statement *stmt, unsigned int index,
1979const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect,
1980const UString &schemaName,
1981const UString &typeName)
1982{
1983 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
1984 OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
1985 unsigned int size = vect.size();
1986 vec_ref.reserve( size );
1987 vec_ind.reserve( size );
1988
1989 for (unsigned int i = 0; i < size; i++)
1990 {
1991 vec_ref.push_back((void *)vect[i].getRef());
1992 vec_ind.push_back( vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
1993 }
1994
1995 setVectorOfOCIRefs(stmt, index, vec_ref, vec_ind, schemaName, typeName);
1996}
1997
1998/*------------------------ getVectorOfRefs for Ref<T> ----------------------*/
1999/*
2000 NAME
2001 getVectorOfRefs - overloaded function. Retrieves the attribute in the
2002 current position as a vector of Ref<T>
2003
2004 PARAMETERS
2005 stmt - Statement
2006 vect- reference to vector of Ref<T>(OUT parameter).
2007
2008 DESCRIPTION
2009 Retrieves the column in the specified position as a vector of Ref<T>.
2010 The attribute at the current position should be a collection type (varray or
2011 nested table). The SQL type of the elements in the collection should be
2012 compatible with Ref<T>.
2013
2014 RETURNS
2015 nothing
2016
2017 NOTES
2018 compatible SQL types : REF
2019*/
2020
2021template <class T>
2022void getVectorOfRefs( Statement *stmt, unsigned int index,
2023OCCI_STD_NAMESPACE::vector <Ref<T> > &vect)
2024{
2025 OCCI_STD_NAMESPACE::vector<void *> vec_ref;
2026 getVectorOfOCIRefs(stmt, index, vec_ref);
2027
2028 const Connection *sess = stmt->getConnection();
2029
2030 vect.clear();
2031 unsigned int size = vec_ref.size();
2032 vect.reserve( size );
2033 for (unsigned int i=0; i< size; i++)
2034 {
2035 if (vec_ref[i] == (OCIRef *)0)
2036 vect.push_back(Ref <T>()); // pushing a default-constructed Ref
2037 else
2038 vect.push_back(Ref<T> (sess, (OCIRef *)vec_ref[i], FALSE));
2039 }
2040}
2041/*----------------------------- pinVectorOfRefs---------------------*/
2042/*
2043 NAME
2044 pinVectorOfRefs - array pin implementation
2045
2046 PARAMETERS
2047 conn- Connection object
2048 vecRef - vector of OCIRefs *
2049 vecCor - vector of OCIComplexObject *
2050 vecPOBj - vector of PObject * ( OUT )
2051
2052 DESCRIPTION
2053 implements the array pin of refs passed and returns the corresponding
2054 PObject s
2055
2056 RETURNS
2057
2058 NOTES
2059*/
2060template <class T>
2061void pinVectorOfRefs( const Connection *conn,
2062OCCI_STD_NAMESPACE::vector<Ref<T> > &vect,
2063OCCI_STD_NAMESPACE::vector<T* > &vectObj, LockOptions lockOpt)
2064{
2065
2066 OCCI_STD_NAMESPACE::vector<void *> vecRef;
2067 OCCI_STD_NAMESPACE::vector<void *> vecCor;
2068 OCCI_STD_NAMESPACE::vector<PObject *> vecPObj;
2069 unsigned int sz = vect.size();
2070 vecRef.reserve( sz );
2071 vecCor.reserve( sz );
2072
2073 for ( unsigned int i=0; i < sz; i++)
2074 {
2075 vecRef.push_back((void *)vect[i].getRef());
2076 vecCor.push_back((void *)vect[i].getCor());
2077 }
2078 pinVectorOfOCIRefs(conn, vecRef, vecCor, vecPObj, lockOpt);
2079 for ( unsigned int k=0; k < sz; k++)
2080 {
2081 vectObj.push_back((T *)vecPObj[k]);
2082 vect[k].setPinnedObject(vecPObj[k]);
2083 }
2084}
2085
2086/*----------------------------- pinVectorOfRefs---------------------*/
2087/*
2088 NAME
2089 pinVectorOfRefs - array pin implementation
2090
2091 PARAMETERS
2092 conn- Connection object
2093 vecRef - vector of OCIRefs *
2094 vecCor - vector of OCIComplexObject *
2095
2096 DESCRIPTION
2097 implements the array pin of refs passed
2098
2099 RETURNS
2100
2101 NOTES
2102*/
2103template <class T>
2104void pinVectorOfRefs( const Connection *conn,
2105OCCI_STD_NAMESPACE::vector<Ref<T> > &vect,
2106LockOptions lockOpt)
2107{
2108
2109 OCCI_STD_NAMESPACE::vector<void *> vecRef;
2110 OCCI_STD_NAMESPACE::vector<void *> vecCor;
2111 OCCI_STD_NAMESPACE::vector<PObject *> vecPObj;
2112 unsigned int sz = vect.size();
2113 vecRef.reserve( sz );
2114 vecCor.reserve( sz );
2115
2116 for ( unsigned int i=0; i < sz; i++)
2117 {
2118 vecRef.push_back((void *)vect[i].getRef());
2119 vecCor.push_back((void *)vect[i].getCor());
2120 }
2121 pinVectorOfOCIRefs(conn, vecRef, vecCor,vecPObj, lockOpt);
2122 for ( unsigned int k=0; k < sz; k++)
2123 vect[k].setPinnedObject(vecPObj[k]);
2124}
2125
2126
2127
2128/*---------------------------------------------------------------------------
2129 INTERNAL FUNCTIONS
2130 ---------------------------------------------------------------------------*/
2131
2132
2133} /* end of namespace occi */
2134} /* end of namespace oracle */
2135#endif /* OCCICONTROL_ORACLE */
2136
2137#endif /* _olint */