OCILIB (C and C++ Driver for Oracle)  4.7.6
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
BindsHolder.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/support.hpp"
24 
25 namespace ocilib
26 {
27  namespace support
28  {
29  inline BindsHolder::BindsHolder(const ocilib::Statement& statement) : _statement(statement)
30  {
31 
32  }
33 
34  inline BindsHolder::~BindsHolder() noexcept
35  {
36  Clear();
37  }
38 
39  inline void BindsHolder::Clear()
40  {
41  std::vector<BindObject*>::iterator it, it_end;
42 
43  for (it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it)
44  {
45  delete core::OnDeallocate(*it);
46  }
47 
48  _bindObjects.clear();
49  }
50 
51  inline void BindsHolder::AddBindObject(BindObject* bindObject)
52  {
53  if (core::Check(OCI_IsRebindingAllowed(_statement)))
54  {
55  std::vector<BindObject*>::iterator it, it_end;
56 
57  for (it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it)
58  {
59  BindObject* previousBindObject = *it;
60  if (previousBindObject->GetName() == bindObject->GetName())
61  {
62  _bindObjects.erase(it);
63  delete core::OnDeallocate(previousBindObject);
64  break;
65  }
66  }
67  }
68 
69  _bindObjects.push_back(bindObject);
70  }
71 
72  inline void BindsHolder::SetOutData()
73  {
74  std::vector<BindObject*>::iterator it, it_end;
75 
76  for (it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it)
77  {
78  (*it)->SetOutData();
79  }
80  }
81 
82  inline void BindsHolder::SetInData()
83  {
84  std::vector<BindObject*>::iterator it, it_end;
85 
86  for (it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it)
87  {
88  (*it)->SetInData();
89  }
90  }
91  }
92 }
Object used for executing SQL or PL/SQL statement and returning the produced results.
Definition: types.hpp:5559
OCI_SYM_PUBLIC boolean OCI_API OCI_IsRebindingAllowed(OCI_Statement *stmt)
Indicate if rebinding is allowed on the given statement.
OCILIB ++ Namespace.