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