OCILIB (C and C++ Driver for Oracle)  4.7.6
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Statement.hpp
1 /*
2  * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI)
3  *
4  * Website: http://www.ocilib.net
5  *
6  * Copyright (c) 2007-2023 Vincent ROGIER <vince.rogier@ocilib.net>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #pragma once
22 
23 #include "ocilibcpp/types.hpp"
24 
25  // ReSharper disable CppUseAuto
26  // ReSharper disable CppParameterMayBeConst
27  // ReSharper disable CppClangTidyCppcoreguidelinesMacroUsage
28  // ReSharper disable CppClangTidyModernizeReturnBracedInitList
29  // ReSharper disable CppClangTidyModernizePassByValue
30  // ReSharper disable CppClangTidyHicppUseAuto
31  // ReSharper disable CppClangTidyModernizeUseAuto
32  // ReSharper disable CppClangTidyReadabilityInconsistentDeclarationParameterName
33  // ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam
34  // ReSharper disable CppClangTidyHicppUseEqualsDefault
35  // ReSharper disable CppClangTidyModernizeLoopConvert
36  // ReSharper disable CppClangTidyModernizeUseEmplace
37  // ReSharper disable CppClangTidyModernizeUseEqualsDefault
38  // ReSharper disable CppClangTidyHicppUseEmplace
39  // ReSharper disable CppClangTidyCertOop54Cpp
40  // ReSharper disable CppClangTidyMiscMisplacedConst
41  // ReSharper disable CppClangTidyBugproneUnhandledSelfAssignment
42 
43 namespace ocilib
44 {
45 
47 {
48 }
49 
50 inline Statement::Statement(const Connection &connection)
51 {
52  AcquireAllocatedWithNotification
53  (
54  core::Check(OCI_StatementCreate(connection)),
55  connection.GetHandle(),
56  OnFreeSmartHandle
57  );
58 }
59 
60 inline Statement::Statement(OCI_Statement *stmt, core::Handle *parent)
61 {
62  AcquireTransient(stmt, parent);
63 }
64 
66 {
67  return Connection(core::Check(OCI_StatementGetConnection(*this)), Environment::GetEnvironmentHandle());
68 }
69 
70 inline void Statement::Describe(const ostring& sql)
71 {
72  ClearBinds();
73  ReleaseResultsets();
74  core::Check(OCI_Describe(*this, sql.c_str()));
75 }
76 
77 inline void Statement::Parse(const ostring& sql)
78 {
79  ClearBinds();
80  ReleaseResultsets();
81  core::Check(OCI_Parse(*this, sql.c_str()));
82 }
83 
84 inline void Statement::Prepare(const ostring& sql)
85 {
86  ClearBinds();
87  ReleaseResultsets();
88  core::Check(OCI_Prepare(*this, sql.c_str()));
89 }
90 
92 {
93  ReleaseResultsets();
94  SetInData();
95  core::Check(OCI_Execute(*this));
96  SetOutData();
97 }
98 
99 template<class T>
100 unsigned int Statement::ExecutePrepared(T callback)
101 {
102  ExecutePrepared();
103 
104  return Fetch(callback);
105 }
106 
107 template<class T, class U>
108 unsigned int Statement::ExecutePrepared(T callback, U adapter)
109 {
110  ExecutePrepared();
111 
112  return Fetch(callback, adapter);
113 }
114 
115 inline void Statement::Execute(const ostring& sql)
116 {
117  ClearBinds();
118  ReleaseResultsets();
119  core::Check(OCI_ExecuteStmt(*this, sql.c_str()));
120 }
121 
122 template<class T>
123 unsigned int Statement::Execute(const ostring& sql, T callback)
124 {
125  Execute(sql);
126 
127  return Fetch(callback);
128 }
129 
130 template<class T, class U>
131 unsigned int Statement::Execute(const ostring& sql, T callback, U adapter)
132 {
133  Execute(sql);
134 
135  return Fetch(callback, adapter);
136 }
137 
138 template<typename T>
139 unsigned int Statement::Fetch(T callback)
140 {
141  unsigned int res = 0;
142 
143  Resultset rs = GetResultset();
144 
145  while (rs)
146  {
147  res += rs.ForEach(callback);
148  rs = GetNextResultset();
149  }
150 
151  return res;
152 }
153 
154 template<class T, class U>
155 unsigned int Statement::Fetch(T callback, U adapter)
156 {
157  unsigned int res = 0;
158 
159  Resultset rs = GetResultset();
160 
161  while (rs)
162  {
163  res += rs.ForEach(callback, adapter);
164  rs = GetNextResultset();
165  }
166 
167  return res;
168 }
169 
170 inline unsigned int Statement::GetAffectedRows() const
171 {
172  return core::Check(OCI_GetAffectedRows(*this));
173 }
174 
176 {
177  return core::MakeString(core::Check(OCI_GetSql(*this)));
178 }
179 
181 {
183 }
184 
186 {
187  return Resultset(core::Check(OCI_GetResultset(*this)), GetHandle());
188 }
189 
191 {
192  return Resultset(core::Check(OCI_GetNextResultset(*this)), GetHandle());
193 }
194 
195 inline void Statement::SetBindArraySize(unsigned int size)
196 {
197  core::Check(OCI_BindArraySetSize(*this, size));
198 }
199 
200 inline unsigned int Statement::GetBindArraySize() const
201 {
202  return core::Check(OCI_BindArrayGetSize(*this));
203 }
204 
205 inline void Statement::AllowRebinding(bool value)
206 {
207  core::Check(OCI_AllowRebinding(*this, value));
208 }
209 
210 inline bool Statement::IsRebindingAllowed() const
211 {
212  return (core::Check(OCI_IsRebindingAllowed(*this)) == TRUE);
213 }
214 
215 inline unsigned int Statement::GetBindIndex(const ostring& name) const
216 {
217  return core::Check(OCI_GetBindIndex(*this, name.c_str()));
218 }
219 
220 inline unsigned int Statement::GetBindCount() const
221 {
222  return core::Check(OCI_GetBindCount(*this));
223 }
224 
225 inline BindInfo Statement::GetBind(unsigned int index) const
226 {
227  return BindInfo(core::Check(OCI_GetBind(*this, index)), GetHandle());
228 }
229 
230 inline BindInfo Statement::GetBind(const ostring& name) const
231 {
232  return BindInfo(core::Check(OCI_GetBind2(*this, name.c_str())), GetHandle());
233 }
234 
235 template<typename M, class T>
236 void Statement::Bind1(M &method, const ostring& name, T& value, BindInfo::BindDirection mode)
237 {
238  core::Check(method(*this, name.c_str(), &value));
239  SetLastBindMode(mode);
240 }
241 
242 template<typename M, class T>
243 void Statement::Bind2(M &method, const ostring& name, T& value, BindInfo::BindDirection mode)
244 {
245  core::Check(method(*this, name.c_str(), static_cast<typename support::BindResolver<T>::OutputType>(value)));
246  SetLastBindMode(mode);
247 }
248 
249 template<typename M, class T>
250 void Statement::BindVector1(M &method, const ostring& name, std::vector<T> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
251 {
252  support::BindArray * bnd = core::OnAllocate(new support::BindArray(*this, name, mode));
253  bnd->SetVector<T>(values, type == BindInfo::AsPlSqlTable, sizeof(typename support::BindResolver<T>::OutputType));
254 
255  const boolean res = method(*this, name.c_str(), bnd->GetData<T>(), bnd->GetSizeForBindCall());
256 
257  if (res)
258  {
259  support::BindsHolder *bindsHolder = GetBindsHolder(true);
260  bindsHolder->AddBindObject(bnd);
261  SetLastBindMode(mode);
262  }
263  else
264  {
265  delete core::OnDeallocate(bnd);
266  }
267 
268  core::Check(res);
269 }
270 
271 template<typename M, class T, class U>
272 void Statement::BindVector2(M &method, const ostring& name, std::vector<T> &values, BindInfo::BindDirection mode, U subType, BindInfo::VectorType type)
273 {
274  support::BindArray * bnd = core::OnAllocate(new support::BindArray(*this, name, mode));
275  bnd->SetVector<T>(values, type == BindInfo::AsPlSqlTable, sizeof(typename support::BindResolver<T>::OutputType));
276 
277  const boolean res = method(*this, name.c_str(), bnd->GetData<T>(), subType, bnd->GetSizeForBindCall());
278 
279  if (res)
280  {
281  support::BindsHolder *bindsHolder = GetBindsHolder(true);
282  bindsHolder->AddBindObject(bnd);
283  SetLastBindMode(mode);
284  }
285  else
286  {
287  delete core::OnDeallocate(bnd);
288  }
289 
290  core::Check(res);
291 }
292 
293 template<>
294 inline void Statement::Bind<bool>(const ostring& name, bool &value, BindInfo::BindDirection mode)
295 {
296  support::BindTypeAdaptor<bool> * bnd = core::OnAllocate(new support::BindTypeAdaptor<bool>(*this, name, mode, value));
297 
298  const boolean res = OCI_BindBoolean(*this, name.c_str(), static_cast<boolean *>(*bnd));
299 
300  if (res)
301  {
302  support::BindsHolder *bindsHolder = GetBindsHolder(true);
303  bindsHolder->AddBindObject(bnd);
304  SetLastBindMode(mode);
305  }
306  else
307  {
308  delete core::OnDeallocate(bnd);
309  }
310 
311  core::Check(res);
312 }
313 
314 template<>
315 inline void Statement::Bind<short>(const ostring& name, short &value, BindInfo::BindDirection mode)
316 {
317  Bind1(OCI_BindShort, name, value, mode);
318 }
319 
320 template<>
321 inline void Statement::Bind<unsigned short>(const ostring& name, unsigned short &value, BindInfo::BindDirection mode)
322 {
323  Bind1(OCI_BindUnsignedShort, name, value, mode);
324 }
325 
326 template<>
327 inline void Statement::Bind<int>(const ostring& name, int &value, BindInfo::BindDirection mode)
328 {
329  Bind1(OCI_BindInt, name, value, mode);
330 }
331 
332 template<>
333 inline void Statement::Bind<unsigned int>(const ostring& name, unsigned int &value, BindInfo::BindDirection mode)
334 {
335  Bind1(OCI_BindUnsignedInt, name, value, mode);
336 }
337 
338 template<>
339 inline void Statement::Bind<big_int>(const ostring& name, big_int &value, BindInfo::BindDirection mode)
340 {
341  Bind1(OCI_BindBigInt, name, value, mode);
342 }
343 
344 template<>
345 inline void Statement::Bind<big_uint>(const ostring& name, big_uint &value, BindInfo::BindDirection mode)
346 {
347  Bind1(OCI_BindUnsignedBigInt, name, value, mode);
348 }
349 
350 template<>
351 inline void Statement::Bind<float>(const ostring& name, float &value, BindInfo::BindDirection mode)
352 {
353  Bind1(OCI_BindFloat, name, value, mode);
354 }
355 
356 template<>
357 inline void Statement::Bind<double>(const ostring& name, double &value, BindInfo::BindDirection mode)
358 {
359  Bind1(OCI_BindDouble, name, value, mode);
360 }
361 
362 template<>
363 inline void Statement::Bind<Number>(const ostring& name, Number &value, BindInfo::BindDirection mode)
364 {
365  Bind2(OCI_BindNumber, name, value, mode);
366 }
367 
368 template<>
369 inline void Statement::Bind<Date>(const ostring& name, Date &value, BindInfo::BindDirection mode)
370 {
371  Bind2(OCI_BindDate, name, value, mode);
372 }
373 
374 template<>
375 inline void Statement::Bind<Timestamp>(const ostring& name, Timestamp &value, BindInfo::BindDirection mode)
376 {
377  Bind2(OCI_BindTimestamp, name, value, mode);
378 }
379 
380 template<>
381 inline void Statement::Bind<Interval>(const ostring& name, Interval &value, BindInfo::BindDirection mode)
382 {
383  Bind2(OCI_BindInterval, name, value, mode);
384 }
385 
386 template<>
387 inline void Statement::Bind<Clob>(const ostring& name, Clob &value, BindInfo::BindDirection mode)
388 {
389  Bind2(OCI_BindLob, name, value, mode);
390 }
391 
392 template<>
393 inline void Statement::Bind<NClob>(const ostring& name, NClob &value, BindInfo::BindDirection mode)
394 {
395  Bind2(OCI_BindLob, name, value, mode);
396 }
397 
398 template<>
399 inline void Statement::Bind<Blob>(const ostring& name, Blob &value, BindInfo::BindDirection mode)
400 {
401  Bind2(OCI_BindLob, name, value, mode);
402 }
403 
404 template<>
405 inline void Statement::Bind<File>(const ostring& name, File &value, BindInfo::BindDirection mode)
406 {
407  Bind2(OCI_BindFile, name, value, mode);
408 }
409 
410 template<>
411 inline void Statement::Bind<Object>(const ostring& name, Object &value, BindInfo::BindDirection mode)
412 {
413  Bind2(OCI_BindObject, name, value, mode);
414 }
415 
416 template<>
417 inline void Statement::Bind<Reference>(const ostring& name, Reference &value, BindInfo::BindDirection mode)
418 {
419  Bind2(OCI_BindRef, name, value, mode);
420 }
421 
422 template<>
423 inline void Statement::Bind<Statement>(const ostring& name, Statement &value, BindInfo::BindDirection mode)
424 {
425  Bind2(OCI_BindStatement, name, value, mode);
426 }
427 
428 template<>
429 inline void Statement::Bind<Clong, unsigned int>(const ostring& name, Clong &value, unsigned int maxSize, BindInfo::BindDirection mode)
430 {
431  core::Check(OCI_BindLong(*this, name.c_str(), value, maxSize));
432  SetLastBindMode(mode);
433 }
434 
435 template<>
436 inline void Statement::Bind<Clong, int>(const ostring& name, Clong &value, int maxSize, BindInfo::BindDirection mode)
437 {
438  Bind<Clong, unsigned int>(name, value, static_cast<unsigned int>(maxSize), mode);
439 }
440 
441 template<>
442 inline void Statement::Bind<Blong, unsigned int>(const ostring& name, Blong &value, unsigned int maxSize, BindInfo::BindDirection mode)
443 {
444  core::Check(OCI_BindLong(*this, name.c_str(), value, maxSize));
445  SetLastBindMode(mode);
446 }
447 
448 template<>
449 inline void Statement::Bind<Blong, int>(const ostring& name, Blong &value, int maxSize, BindInfo::BindDirection mode)
450 {
451  Bind<Blong, unsigned int>(name, value, static_cast<unsigned int>(maxSize), mode);
452 }
453 
454 template<>
455 inline void Statement::Bind<ostring, unsigned int>(const ostring& name, ostring &value, unsigned int maxSize, BindInfo::BindDirection mode)
456 {
457  if (maxSize == 0)
458  {
459  maxSize = static_cast<unsigned int>(value.size());
460  }
461 
462  value.reserve(maxSize);
463 
464  support::BindObjectAdaptor<ostring> * bnd = core::OnAllocate(new support::BindObjectAdaptor<ostring>(*this, name, mode, value, maxSize + 1));
465 
466  const boolean res = OCI_BindString(*this, name.c_str(), static_cast<otext *>(*bnd), maxSize);
467 
468  if (res)
469  {
470  support::BindsHolder *bindsHolder = GetBindsHolder(true);
471  bindsHolder->AddBindObject(bnd);
472  SetLastBindMode(mode);
473  }
474  else
475  {
476  delete core::OnDeallocate(bnd);
477  }
478 
479  core::Check(res);
480 }
481 
482 template<>
483 inline void Statement::Bind<ostring, int>(const ostring& name, ostring &value, int maxSize, BindInfo::BindDirection mode)
484 {
485  Bind<ostring, unsigned int>(name, value, static_cast<unsigned int>(maxSize), mode);
486 }
487 
488 template<>
489 inline void Statement::Bind<Raw, unsigned int>(const ostring& name, Raw &value, unsigned int maxSize, BindInfo::BindDirection mode)
490 {
491  if (maxSize == 0)
492  {
493  maxSize = static_cast<unsigned int>(value.size());
494  }
495 
496  value.reserve(maxSize);
497 
498  support::BindObjectAdaptor<Raw> * bnd = core::OnAllocate(new support::BindObjectAdaptor<Raw>(*this, name, mode, value, maxSize));
499 
500  const boolean res = OCI_BindRaw(*this, name.c_str(), static_cast<unsigned char *>(*bnd), maxSize);
501 
502  if (res)
503  {
504  support::BindsHolder *bindsHolder = GetBindsHolder(true);
505  bindsHolder->AddBindObject(bnd);
506  SetLastBindMode(mode);
507  }
508  else
509  {
510  delete core::OnDeallocate(bnd);
511  }
512 
513  core::Check(res);
514 }
515 
516 template<>
517 inline void Statement::Bind<Raw, int>(const ostring& name, Raw &value, int maxSize, BindInfo::BindDirection mode)
518 {
519  Bind<Raw, unsigned int>(name, value, static_cast<unsigned int>(maxSize), mode);
520 }
521 
522 template<>
523 inline void Statement::Bind<short>(const ostring& name, std::vector<short> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
524 {
525  BindVector1(OCI_BindArrayOfShorts, name, values, mode, type);
526 }
527 
528 template<>
529 inline void Statement::Bind<unsigned short>(const ostring& name, std::vector<unsigned short> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
530 {
531  BindVector1(OCI_BindArrayOfUnsignedShorts, name, values, mode, type);
532 }
533 
534 template<>
535 inline void Statement::Bind<int>(const ostring& name, std::vector<int> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
536 {
537  BindVector1(OCI_BindArrayOfInts, name, values, mode, type);
538 }
539 
540 template<>
541 inline void Statement::Bind<unsigned int>(const ostring& name, std::vector<unsigned int> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
542 {
543  BindVector1(OCI_BindArrayOfUnsignedInts, name, values, mode, type);
544 }
545 
546 template<>
547 inline void Statement::Bind<big_int>(const ostring& name, std::vector<big_int> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
548 {
549  BindVector1(OCI_BindArrayOfBigInts, name, values, mode, type);
550 }
551 
552 template<>
553 inline void Statement::Bind<big_uint>(const ostring& name, std::vector<big_uint> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
554 {
555  BindVector1(OCI_BindArrayOfUnsignedBigInts, name, values, mode, type);
556 }
557 
558 template<>
559 inline void Statement::Bind<float>(const ostring& name, std::vector<float> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
560 {
561  BindVector1(OCI_BindArrayOfFloats, name, values, mode, type);
562 }
563 
564 template<>
565 inline void Statement::Bind<double>(const ostring& name, std::vector<double> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
566 {
567  BindVector1(OCI_BindArrayOfDoubles, name, values, mode, type);
568 }
569 
570 template<>
571 inline void Statement::Bind<Date>(const ostring& name, std::vector<Date> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
572 {
573  BindVector1(OCI_BindArrayOfDates, name, values, mode, type);
574 }
575 
576 template<>
577 inline void Statement::Bind<Number>(const ostring& name, std::vector<Number> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
578 {
579  BindVector1(OCI_BindArrayOfNumbers, name, values, mode, type);
580 }
581 
582 template<class T>
584 {
585  core::Check(OCI_BindColl(*this, name.c_str(), value));
586  SetLastBindMode(mode);
587 }
588 
589 template<>
590 inline void Statement::Bind<Timestamp, Timestamp::TimestampTypeValues>(const ostring& name, std::vector<Timestamp> &values, Timestamp::TimestampTypeValues subType, BindInfo::BindDirection mode, BindInfo::VectorType type)
591 {
592  BindVector2(OCI_BindArrayOfTimestamps, name, values, mode, subType, type);
593 }
594 
595 template<>
596 inline void Statement::Bind<Timestamp, Timestamp::TimestampType>(const ostring& name, std::vector<Timestamp> &values, Timestamp::TimestampType subType, BindInfo::BindDirection mode, BindInfo::VectorType type)
597 {
598  Bind<Timestamp, Timestamp::TimestampTypeValues>(name, values, subType.GetValue(), mode, type);
599 }
600 
601 template<>
602 inline void Statement::Bind<Interval, Interval::IntervalTypeValues>(const ostring& name, std::vector<Interval> &values, Interval::IntervalTypeValues subType, BindInfo::BindDirection mode, BindInfo::VectorType type)
603 {
604  BindVector2(OCI_BindArrayOfIntervals, name, values, mode, subType, type);
605 }
606 
607 template<>
608 inline void Statement::Bind<Interval, Interval::IntervalType>(const ostring& name, std::vector<Interval> &values, Interval::IntervalType subType, BindInfo::BindDirection mode, BindInfo::VectorType type)
609 {
610  Bind<Interval, Interval::IntervalTypeValues>(name, values, subType.GetValue(), mode, type);
611 }
612 
613 template<>
614 inline void Statement::Bind<Clob>(const ostring& name, std::vector<Clob> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
615 {
616  BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast<unsigned int>(OCI_CLOB), type);
617 }
618 
619 template<>
620 inline void Statement::Bind<NClob>(const ostring& name, std::vector<NClob> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
621 {
622  BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast<unsigned int>(OCI_NCLOB), type);
623 }
624 
625 template<>
626 inline void Statement::Bind<Blob>(const ostring& name, std::vector<Blob> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
627 {
628  BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast<unsigned int>(OCI_BLOB), type);
629 }
630 
631 template<>
632 inline void Statement::Bind<File>(const ostring& name, std::vector<File> &values, BindInfo::BindDirection mode, BindInfo::VectorType type)
633 {
634  BindVector2(OCI_BindArrayOfFiles, name, values, mode, static_cast<unsigned int>(OCI_BFILE), type);
635 }
636 
637 template<>
638 inline void Statement::Bind<Object>(const ostring& name, std::vector<Object> &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type)
639 {
640  BindVector2(OCI_BindArrayOfObjects, name, values, mode, static_cast<OCI_TypeInfo *>(typeInfo), type);
641 }
642 
643 template<>
644 inline void Statement::Bind<Reference>(const ostring& name, std::vector<Reference> &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type)
645 {
646  BindVector2(OCI_BindArrayOfRefs, name, values, mode, static_cast<OCI_TypeInfo *>(typeInfo), type);
647 }
648 
649 template<class T>
650 void Statement::Bind(const ostring& name, std::vector<Collection<T> > &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type)
651 {
652  BindVector2(OCI_BindArrayOfColls, name, values, mode, static_cast<OCI_TypeInfo *>(typeInfo), type);
653 }
654 
655 template<>
656 inline void Statement::Bind<ostring, unsigned int>(const ostring& name, std::vector<ostring> &values, unsigned int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type)
657 {
658  support::BindArray * bnd = core::OnAllocate(new support::BindArray(*this, name, mode));
659  bnd->SetVector<ostring>(values, type == BindInfo::AsPlSqlTable, maxSize+1);
660 
661  const boolean res = OCI_BindArrayOfStrings(*this, name.c_str(), bnd->GetData<ostring>(), maxSize, bnd->GetSizeForBindCall());
662 
663  if (res)
664  {
665  support::BindsHolder *bindsHolder = GetBindsHolder(true);
666  bindsHolder->AddBindObject(bnd);
667  SetLastBindMode(mode);
668  }
669  else
670  {
671  delete core::OnDeallocate(bnd);
672  }
673 
674  core::Check(res);
675 }
676 
677 template<>
678 inline void Statement::Bind<ostring, int>(const ostring& name, std::vector<ostring> &values, int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type)
679 {
680  Bind<ostring, unsigned int>(name, values, static_cast<unsigned int>(maxSize), mode, type);
681 }
682 
683 template<>
684 inline void Statement::Bind<Raw, unsigned int>(const ostring& name, std::vector<Raw> &values, unsigned int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type)
685 {
686  support::BindArray * bnd = core::OnAllocate(new support::BindArray(*this, name, mode));
687  bnd->SetVector<Raw>(values, type == BindInfo::AsPlSqlTable, maxSize);
688 
689  const boolean res = OCI_BindArrayOfRaws(*this, name.c_str(), bnd->GetData<Raw>(), maxSize, bnd->GetSizeForBindCall());
690 
691  if (res)
692  {
693  support::BindsHolder *bindsHolder = GetBindsHolder(true);
694  bindsHolder->AddBindObject(bnd);
695  SetLastBindMode(mode);
696  }
697  else
698  {
699  delete core::OnDeallocate(bnd);
700  }
701 
702  core::Check(res);
703 }
704 
705 template<class T>
706 void Statement::Bind(const ostring& name, std::vector<T> &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type)
707 {
708  BindVector2(OCI_BindArrayOfColls, name, values, mode, static_cast<OCI_TypeInfo *>(typeInfo), GetArraysize(type, values));
709 }
710 
711 template<>
712 inline void Statement::Register<unsigned short>(const ostring& name)
713 {
714  core::Check(OCI_RegisterUnsignedShort(*this, name.c_str()));
715 }
716 
717 template<>
718 inline void Statement::Register<short>(const ostring& name)
719 {
720  core::Check(OCI_RegisterShort(*this, name.c_str()));
721 }
722 
723 template<>
724 inline void Statement::Register<unsigned int>(const ostring& name)
725 {
726  core::Check(OCI_RegisterUnsignedInt(*this, name.c_str()));
727 }
728 
729 template<>
730 inline void Statement::Register<int>(const ostring& name)
731 {
732  core::Check(OCI_RegisterInt(*this, name.c_str()));
733 }
734 
735 template<>
736 inline void Statement::Register<big_uint>(const ostring& name)
737 {
738  core::Check(OCI_RegisterUnsignedBigInt(*this, name.c_str()));
739 }
740 
741 template<>
742 inline void Statement::Register<big_int>(const ostring& name)
743 {
744  core::Check(OCI_RegisterBigInt(*this, name.c_str()));
745 }
746 
747 template<>
748 inline void Statement::Register<float>(const ostring& name)
749 {
750  core::Check(OCI_RegisterFloat(*this, name.c_str()));
751 }
752 
753 template<>
754 inline void Statement::Register<double>(const ostring& name)
755 {
756  core::Check(OCI_RegisterDouble(*this, name.c_str()));
757 }
758 
759 template<>
760 inline void Statement::Register<Number>(const ostring& name)
761 {
762  core::Check(OCI_RegisterNumber(*this, name.c_str()));
763 }
764 
765 template<>
766 inline void Statement::Register<Date>(const ostring& name)
767 {
768  core::Check(OCI_RegisterDate(*this, name.c_str()));
769 }
770 
771 template<>
772 inline void Statement::Register<Timestamp, Timestamp::TimestampTypeValues>(const ostring& name, Timestamp::TimestampTypeValues type)
773 {
774  core::Check(OCI_RegisterTimestamp(*this, name.c_str(), type));
775 }
776 
777 template<>
778 inline void Statement::Register<Timestamp, Timestamp::TimestampType>(const ostring& name, Timestamp::TimestampType type)
779 {
780  Register<Timestamp, Timestamp::TimestampTypeValues>(name, type.GetValue());
781 }
782 
783 template<>
784 inline void Statement::Register<Interval, Interval::IntervalTypeValues>(const ostring& name, Interval::IntervalTypeValues type)
785 {
786  core::Check(OCI_RegisterInterval(*this, name.c_str(), type));
787 }
788 
789 template<>
790 inline void Statement::Register<Interval, Interval::IntervalType>(const ostring& name, Interval::IntervalType type)
791 {
792  Register<Interval, Interval::IntervalTypeValues>(name, type.GetValue());
793 }
794 
795 template<>
796 inline void Statement::Register<Clob>(const ostring& name)
797 {
798  core::Check(OCI_RegisterLob(*this, name.c_str(), OCI_CLOB));
799 }
800 
801 template<>
802 inline void Statement::Register<NClob>(const ostring& name)
803 {
804  core::Check(OCI_RegisterLob(*this, name.c_str(), OCI_NCLOB));
805 }
806 
807 template<>
808 inline void Statement::Register<Blob>(const ostring& name)
809 {
810  core::Check(OCI_RegisterLob(*this, name.c_str(), OCI_BLOB));
811 }
812 
813 template<>
814 inline void Statement::Register<File>(const ostring& name)
815 {
816  core::Check(OCI_RegisterFile(*this, name.c_str(), OCI_BFILE));
817 }
818 
819 template<>
820 inline void Statement::Register<Object, TypeInfo>(const ostring& name, TypeInfo& typeInfo)
821 {
822  core::Check(OCI_RegisterObject(*this, name.c_str(), typeInfo));
823 }
824 
825 template<>
826 inline void Statement::Register<Reference, TypeInfo>(const ostring& name, TypeInfo& typeInfo)
827 {
828  core::Check(OCI_RegisterRef(*this, name.c_str(), typeInfo));
829 }
830 
831 template<>
832 inline void Statement::Register<ostring, unsigned int>(const ostring& name, unsigned int len)
833 {
834  core::Check(OCI_RegisterString(*this, name.c_str(), len));
835 }
836 
837 template<>
838 inline void Statement::Register<ostring, int>(const ostring& name, int len)
839 {
840  Register<ostring, unsigned int>(name, static_cast<unsigned int>(len));
841 }
842 
843 template<>
844 inline void Statement::Register<Raw, unsigned int>(const ostring& name, unsigned int len)
845 {
846  core::Check(OCI_RegisterRaw(*this, name.c_str(), len));
847 }
848 
849 template<>
850 inline void Statement::Register<Raw, int>(const ostring& name, int len)
851 {
852  Register<Raw, unsigned int>(name, static_cast<unsigned int>(len));
853 }
854 
856 {
857  return StatementType(static_cast<StatementType::Type>(core::Check(OCI_GetStatementType(*this))));
858 }
859 
860 inline unsigned int Statement::GetSqlErrorPos() const
861 {
862  return core::Check(OCI_GetSqlErrorPos(*this));
863 }
864 
866 {
867  core::Check(OCI_SetFetchMode(*this, value));
868 }
869 
871 {
872  return FetchMode(static_cast<FetchMode::Type>(core::Check(OCI_GetFetchMode(*this))));
873 }
874 
876 {
877  core::Check(OCI_SetBindMode(*this, value));
878 }
879 
881 {
882  return BindMode(static_cast<BindMode::Type>(core::Check(OCI_GetBindMode(*this))));
883 }
884 
885 inline void Statement::SetFetchSize(unsigned int value)
886 {
887  core::Check(OCI_SetFetchSize(*this, value));
888 }
889 
890 inline unsigned int Statement::GetFetchSize() const
891 {
892  return core::Check(OCI_GetFetchSize(*this));
893 }
894 
895 inline void Statement::SetPrefetchSize(unsigned int value)
896 {
897  core::Check(OCI_SetPrefetchSize(*this, value));
898 }
899 
900 inline unsigned int Statement::GetPrefetchSize() const
901 {
902  return core::Check(OCI_GetPrefetchSize(*this));
903 }
904 
905 inline void Statement::SetPrefetchMemory(unsigned int value)
906 {
907  core::Check(OCI_SetPrefetchMemory(*this, value));
908 }
909 
910 inline unsigned int Statement::GetPrefetchMemory() const
911 {
912  return core::Check(OCI_GetPrefetchMemory(*this));
913 }
914 
915 inline void Statement::SetLongMaxSize(unsigned int value)
916 {
917  core::Check(OCI_SetLongMaxSize(*this, value));
918 }
919 
920 inline unsigned int Statement::GetLongMaxSize() const
921 {
922  return core::Check(OCI_GetLongMaxSize(*this));
923 }
924 
926 {
927  core::Check(OCI_SetLongMode(*this, value));
928 }
929 
931 {
932  return LongMode(static_cast<LongMode::Type>(core::Check(OCI_GetLongMode(*this))));
933 }
934 
935 inline unsigned int Statement::GetSQLCommand() const
936 {
937  return core::Check(OCI_GetSQLCommand(*this));
938 }
939 
941 {
943 }
944 
945 inline void Statement::GetBatchErrors(std::vector<Exception> &exceptions)
946 {
947  exceptions.clear();
948 
949  OCI_Error *err = core::Check(OCI_GetBatchError(*this));
950 
951  while (err)
952  {
953  exceptions.push_back(Exception(err));
954 
955  err = core::Check(OCI_GetBatchError(*this));
956  }
957 }
958 
959 inline void Statement::ClearBinds() const
960 {
961  support::BindsHolder *bindsHolder = GetBindsHolder(false);
962 
963  if (bindsHolder)
964  {
965  bindsHolder->Clear();
966  }
967 }
968 
969 inline void Statement::SetOutData() const
970 {
971  support::BindsHolder *bindsHolder = GetBindsHolder(false);
972 
973  if (bindsHolder)
974  {
975  bindsHolder->SetOutData();
976  }
977 }
978 
979 inline void Statement::SetInData() const
980 {
981  support::BindsHolder *bindsHolder = GetBindsHolder(false);
982 
983  if (bindsHolder)
984  {
985  bindsHolder->SetInData();
986  }
987 }
988 
989 inline void Statement::ReleaseResultsets() const
990 {
991  if (_smartHandle)
992  {
993  core::Handle *handle = nullptr;
994 
995  while (_smartHandle->GetChildren().FindIf(IsResultsetHandle, handle))
996  {
997  if (handle)
998  {
999  handle->DetachFromHolders();
1000 
1001  delete core::OnDeallocate(handle);
1002 
1003  handle = nullptr;
1004  }
1005  }
1006  }
1007 }
1008 
1009 inline bool Statement::IsResultsetHandle(core::Handle *handle)
1010 {
1011  Resultset::SmartHandle *smartHandle = dynamic_cast<Resultset::SmartHandle *>(handle);
1012 
1013  return smartHandle != nullptr;
1014 }
1015 
1016 inline void Statement::OnFreeSmartHandle(SmartHandle *smartHandle)
1017 {
1018  if (smartHandle)
1019  {
1020  support::BindsHolder *bindsHolder = static_cast<support::BindsHolder *>(smartHandle->GetExtraInfos());
1021 
1022  smartHandle->SetExtraInfos(nullptr);
1023 
1024  delete core::OnDeallocate(bindsHolder);
1025  }
1026 }
1027 
1028 inline void Statement::SetLastBindMode(BindInfo::BindDirection mode)
1029 {
1031 }
1032 
1033 inline support::BindsHolder * Statement::GetBindsHolder(bool create) const
1034 {
1035  support::BindsHolder * bindsHolder = static_cast<support::BindsHolder *>(_smartHandle->GetExtraInfos());
1036 
1037  if (bindsHolder == nullptr && create)
1038  {
1039  bindsHolder = core::OnAllocate(new support::BindsHolder(*this));
1040  _smartHandle->SetExtraInfos(bindsHolder);
1041  }
1042 
1043  return bindsHolder;
1044 }
1045 
1046 }
Provides SQL bind information.
Definition: types.hpp:5382
core::Enum< VectorTypeValues > VectorType
Vector type.
Definition: types.hpp:5431
core::Enum< BindDirectionValues > BindDirection
Bind direction.
Definition: types.hpp:5409
Object identifying the SQL data types VARRAY and NESTED TABLE.
Definition: types.hpp:5029
A connection or session with a specific database.
Definition: types.hpp:1580
Exception class handling all OCILIB errors.
Definition: types.hpp:358
IntervalTypeValues
Interval types enumerated values.
Definition: types.hpp:3131
core::Enum< IntervalTypeValues > IntervalType
Interval types.
Definition: types.hpp:3145
Database resultset.
Definition: types.hpp:6508
unsigned int ForEach(T callback)
Fetch all rows in the resultset and call the given callback for row.
void SetBindMode(BindMode value)
Set the binding mode of a SQL statement.
Definition: Statement.hpp:875
Statement()
Create an empty null Statement instance.
Definition: Statement.hpp:46
core::Enum< BindModeValues > BindMode
Bind Modes.
Definition: types.hpp:5651
void SetPrefetchMemory(unsigned int value)
Set the amount of memory pre-fetched by OCI Client.
Definition: Statement.hpp:905
unsigned int GetFetchSize() const
Return the number of rows fetched per internal server fetch call.
Definition: Statement.hpp:890
BindMode GetBindMode() const
Return the binding mode of a SQL statement.
Definition: Statement.hpp:880
ostring GetSqlIdentifier() const
Return the server SQL_ID of the last SQL or PL/SQL statement prepared or executed by the statement.
Definition: Statement.hpp:180
void Bind(const ostring &name, T &value, BindInfo::BindDirection mode)
Bind an host variable.
void SetFetchSize(unsigned int value)
Set the number of rows fetched per internal server fetch call.
Definition: Statement.hpp:885
unsigned int GetSQLCommand() const
Return the Oracle SQL code the command held by the statement.
Definition: Statement.hpp:935
void AllowRebinding(bool value)
Allow different host variables to be binded using the same bind name or position between executions o...
Definition: Statement.hpp:205
void Execute(const ostring &sql)
Prepare and execute a SQL statement or PL/SQL block.
Definition: Statement.hpp:115
BindInfo GetBind(unsigned int index) const
Return the bind at the given index in the internal array of bind objects.
Definition: Statement.hpp:225
ostring GetSql() const
Return the last SQL or PL/SQL statement prepared or executed by the statement.
Definition: Statement.hpp:175
void GetBatchErrors(std::vector< Exception > &exceptions)
Returns all errors that occurred within a DML array statement execution.
Definition: Statement.hpp:945
Connection GetConnection() const
Return the connection associated with a statement.
Definition: Statement.hpp:65
void SetBindArraySize(unsigned int size)
Set the input array size for bulk operations.
Definition: Statement.hpp:195
Resultset GetResultset()
Retrieve the resultset from an executed statement.
Definition: Statement.hpp:185
unsigned int GetPrefetchSize() const
Return the number of rows pre-fetched by OCI Client.
Definition: Statement.hpp:900
void Prepare(const ostring &sql)
Prepare a SQL statement or PL/SQL block.
Definition: Statement.hpp:84
unsigned int GetLongMaxSize() const
Return the LONG data type piece buffer size.
Definition: Statement.hpp:920
core::Enum< FetchModeValues > FetchMode
Fetch Modes.
Definition: types.hpp:5629
void Parse(const ostring &sql)
Parse a SQL statement or PL/SQL block.
Definition: Statement.hpp:77
void SetLongMode(LongMode value)
Set the long data type handling mode of a SQL statement.
Definition: Statement.hpp:925
unsigned int GetBindArraySize() const
Return the current input array size for bulk operations.
Definition: Statement.hpp:200
ostring GetSQLVerb() const
Return the verb of the SQL command held by the statement.
Definition: Statement.hpp:940
core::Enum< LongModeValues > LongMode
LONG data type mapping modes.
Definition: types.hpp:5673
unsigned int GetBindCount() const
Return the number of binds currently associated to a statement.
Definition: Statement.hpp:220
core::Enum< StatementTypeValues > StatementType
Statement Type.
Definition: types.hpp:5607
unsigned int GetBindIndex(const ostring &name) const
Return the index of the bind from its name belonging to the statement.
Definition: Statement.hpp:215
LongMode GetLongMode() const
Return the long data type handling mode of a SQL statement.
Definition: Statement.hpp:930
unsigned int GetPrefetchMemory() const
Return the amount of memory used to retrieve rows pre-fetched by OCI Client.
Definition: Statement.hpp:910
void Describe(const ostring &sql)
Describe the select list of a SQL select statement.
Definition: Statement.hpp:70
unsigned int GetAffectedRows() const
Return the number of rows affected by the SQL statement.
Definition: Statement.hpp:170
void ExecutePrepared()
Execute a prepared SQL statement or PL/SQL block.
Definition: Statement.hpp:91
unsigned int GetSqlErrorPos() const
Return the error position (in terms of characters) in the SQL statement where the error occurred in c...
Definition: Statement.hpp:860
FetchMode GetFetchMode() const
Return the fetch mode of a SQL statement.
Definition: Statement.hpp:870
void SetLongMaxSize(unsigned int value)
Set the LONG data type piece buffer size.
Definition: Statement.hpp:915
void SetFetchMode(FetchMode value)
Set the fetch mode of a SQL statement.
Definition: Statement.hpp:865
Resultset GetNextResultset()
Retrieve the next available resultset.
Definition: Statement.hpp:190
bool IsRebindingAllowed() const
Indicate if rebinding is allowed on the statement.
Definition: Statement.hpp:210
StatementType GetStatementType() const
Return the type of a SQL statement.
Definition: Statement.hpp:855
void SetPrefetchSize(unsigned int value)
Set the number of rows pre-fetched by OCI Client.
Definition: Statement.hpp:895
core::Enum< TimestampTypeValues > TimestampType
Type of timestamp.
Definition: types.hpp:3547
TimestampTypeValues
Interval types enumerated values.
Definition: types.hpp:3531
Provides type information on Oracle Database objects.
Definition: types.hpp:4531
Template Enumeration template class providing some type safety to some extends for manipulating enume...
Definition: core.hpp:118
Internal usage. Interface for handling ownership and relationship of a C API handle.
Definition: core.hpp:325
Internal usage. Class implementing bind translations between C++ vectors and C API arrays.
Definition: support.hpp:80
Internal usage. Class owning bind objects allowing to set/get C data prior/after a statement executio...
Definition: support.hpp:213
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfFloats(OCI_Statement *stmt, const otext *name, float *data, unsigned int nbelem)
Bind an array of floats.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindBigInt(OCI_Statement *stmt, const otext *name, big_int *data)
Bind a big integer variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_IsRebindingAllowed(OCI_Statement *stmt)
Indicate if rebinding is allowed on the given statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindFloat(OCI_Statement *stmt, const otext *name, float *data)
Bind a float variable.
OCI_SYM_PUBLIC OCI_Bind *OCI_API OCI_GetBind(OCI_Statement *stmt, unsigned int index)
Return the bind handle at the given index in the internal array of bind handle.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindString(OCI_Statement *stmt, const otext *name, otext *data, unsigned int len)
Bind a string variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindObject(OCI_Statement *stmt, const otext *name, OCI_Object *data)
Bind an object (named type) variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindLob(OCI_Statement *stmt, const otext *name, OCI_Lob *data)
Bind a Lob variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfFiles(OCI_Statement *stmt, const otext *name, OCI_File **data, unsigned int type, unsigned int nbelem)
Bind an array of File handles.
OCI_SYM_PUBLIC boolean OCI_API OCI_AllowRebinding(OCI_Statement *stmt, boolean value)
Allow different host variables to be binded using the same bind name or position between executions o...
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfRaws(OCI_Statement *stmt, const otext *name, void *data, unsigned int len, unsigned int nbelem)
Bind an array of raw buffers.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindFile(OCI_Statement *stmt, const otext *name, OCI_File *data)
Bind a File variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindBoolean(OCI_Statement *stmt, const otext *name, boolean *data)
Bind a boolean variable (PL/SQL ONLY)
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfUnsignedInts(OCI_Statement *stmt, const otext *name, unsigned int *data, unsigned int nbelem)
Bind an array of unsigned integers.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfDoubles(OCI_Statement *stmt, const otext *name, double *data, unsigned int nbelem)
Bind an array of doubles.
OCI_SYM_PUBLIC OCI_Bind *OCI_API OCI_GetBind2(OCI_Statement *stmt, const otext *name)
Return a bind handle from its name.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindRaw(OCI_Statement *stmt, const otext *name, void *data, unsigned int len)
Bind a raw buffer.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfIntervals(OCI_Statement *stmt, const otext *name, OCI_Interval **data, unsigned int type, unsigned int nbelem)
Bind an array of interval handles.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfBigInts(OCI_Statement *stmt, const otext *name, big_int *data, unsigned int nbelem)
Bind an array of big integers.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfLobs(OCI_Statement *stmt, const otext *name, OCI_Lob **data, unsigned int type, unsigned int nbelem)
Bind an array of Lob handles.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfInts(OCI_Statement *stmt, const otext *name, int *data, unsigned int nbelem)
Bind an array of integers.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfUnsignedShorts(OCI_Statement *stmt, const otext *name, unsigned short *data, unsigned int nbelem)
Bind an array of unsigned shorts.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfUnsignedBigInts(OCI_Statement *stmt, const otext *name, big_uint *data, unsigned int nbelem)
Bind an array of unsigned big integers.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindInterval(OCI_Statement *stmt, const otext *name, OCI_Interval *data)
Bind an interval variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfObjects(OCI_Statement *stmt, const otext *name, OCI_Object **data, OCI_TypeInfo *typinf, unsigned int nbelem)
Bind an array of object handles.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindRef(OCI_Statement *stmt, const otext *name, OCI_Ref *data)
Bind a Ref variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindInt(OCI_Statement *stmt, const otext *name, int *data)
Bind an integer variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindLong(OCI_Statement *stmt, const otext *name, OCI_Long *data, unsigned int size)
Bind a Long variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfTimestamps(OCI_Statement *stmt, const otext *name, OCI_Timestamp **data, unsigned int type, unsigned int nbelem)
Bind an array of timestamp handles.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetBindCount(OCI_Statement *stmt)
Return the number of binds currently associated to a statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindSetDirection(OCI_Bind *bnd, unsigned int direction)
Set the direction mode of a bind handle.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfDates(OCI_Statement *stmt, const otext *name, OCI_Date **data, unsigned int nbelem)
Bind an array of dates.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfRefs(OCI_Statement *stmt, const otext *name, OCI_Ref **data, OCI_TypeInfo *typinf, unsigned int nbelem)
Bind an array of Ref handles.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfStrings(OCI_Statement *stmt, const otext *name, otext *data, unsigned int len, unsigned int nbelem)
Bind an array of strings.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindDate(OCI_Statement *stmt, const otext *name, OCI_Date *data)
Bind a date variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindUnsignedShort(OCI_Statement *stmt, const otext *name, unsigned short *data)
Bind an unsigned short variable.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_BindArrayGetSize(OCI_Statement *stmt)
Return the current input array size for bulk operations.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfColls(OCI_Statement *stmt, const otext *name, OCI_Coll **data, OCI_TypeInfo *typinf, unsigned int nbelem)
Bind an array of Collection handles.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindShort(OCI_Statement *stmt, const otext *name, short *data)
Bind an short variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArraySetSize(OCI_Statement *stmt, unsigned int size)
Set the input array size for bulk operations.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindColl(OCI_Statement *stmt, const otext *name, OCI_Coll *data)
Bind a Collection variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindUnsignedInt(OCI_Statement *stmt, const otext *name, unsigned int *data)
Bind an unsigned integer variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindTimestamp(OCI_Statement *stmt, const otext *name, OCI_Timestamp *data)
Bind a timestamp variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindStatement(OCI_Statement *stmt, const otext *name, OCI_Statement *data)
Bind a Statement variable (PL/SQL Ref Cursor)
OCI_SYM_PUBLIC boolean OCI_API OCI_BindDouble(OCI_Statement *stmt, const otext *name, double *data)
Bind a double variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfShorts(OCI_Statement *stmt, const otext *name, short *data, unsigned int nbelem)
Bind an array of shorts.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetBindIndex(OCI_Statement *stmt, const otext *name)
Return the index of the bind from its name belonging to the given statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindUnsignedBigInt(OCI_Statement *stmt, const otext *name, big_uint *data)
Bind an unsigned big integer variable.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindArrayOfNumbers(OCI_Statement *stmt, const otext *name, OCI_Number **data, unsigned int nbelem)
Bind an array of Number.
OCI_SYM_PUBLIC OCI_Error *OCI_API OCI_GetBatchError(OCI_Statement *stmt)
Returns the first or next error that occurred within a DML array statement execution.
OCI_SYM_PUBLIC boolean OCI_API OCI_BindNumber(OCI_Statement *stmt, const otext *name, OCI_Number *data)
Bind an Number variable.
struct OCI_Statement OCI_Statement
Oracle SQL or PL/SQL statement.
Definition: types.h:136
struct OCI_Error OCI_Error
Encapsulates an Oracle or OCILIB exception.
Definition: types.h:390
long long big_int
big_int is a C scalar integer (32 or 64 bits) depending on compiler support for 64bits integers....
Definition: platform.h:281
struct OCI_TypeInfo OCI_TypeInfo
Type info metadata handle.
Definition: types.h:366
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterLob(OCI_Statement *stmt, const otext *name, unsigned int type)
Register a lob output bind placeholder.
OCI_SYM_PUBLIC OCI_Resultset *OCI_API OCI_GetNextResultset(OCI_Statement *stmt)
Retrieve the next available resultset.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterInt(OCI_Statement *stmt, const otext *name)
Register an integer output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterUnsignedInt(OCI_Statement *stmt, const otext *name)
Register an unsigned integer output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterDouble(OCI_Statement *stmt, const otext *name)
Register a double output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterInterval(OCI_Statement *stmt, const otext *name, unsigned int type)
Register an interval output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterTimestamp(OCI_Statement *stmt, const otext *name, unsigned int type)
Register a timestamp output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterShort(OCI_Statement *stmt, const otext *name)
Register a short output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterRef(OCI_Statement *stmt, const otext *name, OCI_TypeInfo *typinf)
Register a Ref output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterUnsignedBigInt(OCI_Statement *stmt, const otext *name)
Register an unsigned big integer output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterUnsignedShort(OCI_Statement *stmt, const otext *name)
Register an unsigned short output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterDate(OCI_Statement *stmt, const otext *name)
Register a date output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterBigInt(OCI_Statement *stmt, const otext *name)
Register a big integer output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterString(OCI_Statement *stmt, const otext *name, unsigned int len)
Register a string output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterRaw(OCI_Statement *stmt, const otext *name, unsigned int len)
Register an raw output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterNumber(OCI_Statement *stmt, const otext *name)
Register a register output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterFile(OCI_Statement *stmt, const otext *name, unsigned int type)
Register a file output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterFloat(OCI_Statement *stmt, const otext *name)
Register a float output bind placeholder.
OCI_SYM_PUBLIC boolean OCI_API OCI_RegisterObject(OCI_Statement *stmt, const otext *name, OCI_TypeInfo *typinf)
Register an object output bind placeholder.
OCI_SYM_PUBLIC OCI_Resultset *OCI_API OCI_GetResultset(OCI_Statement *stmt)
Retrieve the resultset handle from an executed statement.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetPrefetchSize(OCI_Statement *stmt)
Return the number of rows pre-fetched by OCI Client.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetPrefetchMemory(OCI_Statement *stmt, unsigned int size)
Set the amount of memory pre-fetched by OCI Client.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetFetchMode(OCI_Statement *stmt, unsigned int mode)
Set the fetch mode of a SQL statement.
OCI_SYM_PUBLIC OCI_Connection *OCI_API OCI_StatementGetConnection(OCI_Statement *stmt)
Return the connection handle associated with a statement handle.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetPrefetchMemory(OCI_Statement *stmt)
Return the amount of memory used to retrieve rows pre-fetched by OCI Client.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetLongMaxSize(OCI_Statement *stmt)
Return the LONG data type piece buffer size.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetBindMode(OCI_Statement *stmt)
Return the binding mode of a SQL statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetLongMaxSize(OCI_Statement *stmt, unsigned int size)
Set the LONG data type piece buffer size.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetFetchMode(OCI_Statement *stmt)
Return the fetch mode of a SQL statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetBindMode(OCI_Statement *stmt, unsigned int mode)
Set the binding mode of a SQL statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetLongMode(OCI_Statement *stmt, unsigned int mode)
Set the long data type handling mode of a SQL statement.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetLongMode(OCI_Statement *stmt)
Return the long data type handling mode of a SQL statement.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetFetchSize(OCI_Statement *stmt)
Return the number of rows fetched per internal server fetch call.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetPrefetchSize(OCI_Statement *stmt, unsigned int size)
Set the number of rows pre-fetched by OCI Client.
OCI_SYM_PUBLIC boolean OCI_API OCI_SetFetchSize(OCI_Statement *stmt, unsigned int size)
Set the number of rows fetched per internal server fetch call.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetStatementType(OCI_Statement *stmt)
Return the type of a SQL statement.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetAffectedRows(OCI_Statement *stmt)
Return the number of rows affected by the SQL statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_Parse(OCI_Statement *stmt, const otext *sql)
Parse a SQL statement or PL/SQL block.
OCI_SYM_PUBLIC boolean OCI_API OCI_Describe(OCI_Statement *stmt, const otext *sql)
Describe the select list of a SQL select statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_ExecuteStmt(OCI_Statement *stmt, const otext *sql)
Prepare and Execute a SQL statement or PL/SQL block.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetSQLCommand(OCI_Statement *stmt)
Return the Oracle SQL code the command held by the statement handle.
OCI_SYM_PUBLIC const otext *OCI_API OCI_GetSqlIdentifier(OCI_Statement *stmt)
Returns the statement SQL_ID from the server.
OCI_SYM_PUBLIC boolean OCI_API OCI_Prepare(OCI_Statement *stmt, const otext *sql)
Prepare a SQL statement or PL/SQL block.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_GetSqlErrorPos(OCI_Statement *stmt)
Return the error position (in terms of characters) in the SQL statement where the error occurred in c...
OCI_SYM_PUBLIC OCI_Statement *OCI_API OCI_StatementCreate(OCI_Connection *con)
Create a statement object and return its handle.
OCI_SYM_PUBLIC const otext *OCI_API OCI_GetSql(OCI_Statement *stmt)
Return the last SQL or PL/SQL statement prepared or executed by the statement.
OCI_SYM_PUBLIC boolean OCI_API OCI_Execute(OCI_Statement *stmt)
Execute a prepared SQL statement or PL/SQL block.
OCI_SYM_PUBLIC const otext *OCI_API OCI_GetSQLVerb(OCI_Statement *stmt)
Return the verb of the SQL command held by the statement handle.
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so,...
Definition: Utils.hpp:53
ostring MakeString(const otext *result, int size=-1)
Internal usage. Constructs a C++ string object from the given OCILIB string pointer.
Definition: Utils.hpp:65
OCILIB ++ Namespace.
std::basic_string< otext, std::char_traits< otext >, std::allocator< otext > > ostring
string class wrapping the OCILIB otext * type and OTEXT() macros ( see Character sets )
Definition: config.hpp:120
Long< Raw, LongBinary > Blong
Class handling LONG RAW oracle type.
Definition: types.hpp:5372
Lob< ostring, LobNationalCharacter > NClob
Class handling NCLOB oracle type.
Definition: types.hpp:4320
Lob< ostring, LobCharacter > Clob
Class handling CLOB oracle type.
Definition: types.hpp:4309
std::vector< unsigned char > Raw
C++ counterpart of SQL RAW data type.
Definition: config.hpp:138
Long< ostring, LongCharacter > Clong
Class handling LONG oracle type.
Definition: types.hpp:5361
Lob< Raw, LobBinary > Blob
Class handling BLOB oracle type.
Definition: types.hpp:4331