soci-oracle.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 
8 #ifndef SOCI_ORACLE_H_INCLUDED
9 #define SOCI_ORACLE_H_INCLUDED
10 
11 #ifdef _WIN32
12 # ifdef SOCI_DLL
13 # ifdef SOCI_ORACLE_SOURCE
14 # define SOCI_ORACLE_DECL __declspec(dllexport)
15 # else
16 # define SOCI_ORACLE_DECL __declspec(dllimport)
17 # endif // SOCI_ORACLE_SOURCE
18 # endif // SOCI_DLL
19 #endif // _WIN32
20 //
21 // If SOCI_ORACLE_DECL isn't defined yet define it now
22 #ifndef SOCI_ORACLE_DECL
23 # define SOCI_ORACLE_DECL
24 #endif
25 
26 #include <soci-backend.h>
27 #include <oci.h> // OCI
28 #include <vector>
29 
30 #ifdef _MSC_VER
31 #pragma warning(disable:4512 4511)
32 #endif
33 
34 
35 namespace soci
36 {
37 
39 {
40 public:
41  oracle_soci_error(std::string const & msg, int errNum = 0);
42 
43  int err_num_;
44 };
45 
46 
49 {
51  : statement_(st), defnp_(NULL), indOCIHolder_(0),
52  data_(NULL), buf_(NULL) {}
53 
54  virtual void define_by_pos(int &position,
55  void *data, details::exchange_type type);
56 
57  virtual void pre_fetch();
58  virtual void post_fetch(bool gotData, bool calledFromFetch,
59  indicator *ind);
60 
61  virtual void clean_up();
62 
64 
65  OCIDefine *defnp_;
67  void *data_;
68  char *buf_; // generic buffer
70 
71  ub2 rCode_;
72 };
73 
75 {
77  : statement_(st), defnp_(NULL), indOCIHolders_(NULL),
78  data_(NULL), buf_(NULL) {}
79 
80  virtual void define_by_pos(int &position,
81  void *data, details::exchange_type type);
82 
83  virtual void pre_fetch();
84  virtual void post_fetch(bool gotData, indicator *ind);
85 
86  virtual void resize(std::size_t sz);
87  virtual std::size_t size();
88 
89  virtual void clean_up();
90 
91  // helper function for preparing indicators and sizes_ vectors
92  // (as part of the define_by_pos)
93  void prepare_indicators(std::size_t size);
94 
96 
97  OCIDefine *defnp_;
99  std::vector<sb2> indOCIHolderVec_;
100  void *data_;
101  char *buf_; // generic buffer
103  std::size_t colSize_; // size of the string column (used for strings)
104  std::vector<ub2> sizes_; // sizes of data fetched (used for strings)
105 
106  std::vector<ub2> rCodes_;
107 };
108 
110 {
112  : statement_(st), bindp_(NULL), indOCIHolder_(0),
113  data_(NULL), buf_(NULL) {}
114 
115  virtual void bind_by_pos(int &position,
116  void *data, details::exchange_type type, bool readOnly);
117  virtual void bind_by_name(std::string const &name,
118  void *data, details::exchange_type type, bool readOnly);
119 
120  // common part for bind_by_pos and bind_by_name
121  void prepare_for_bind(void *&data, sb4 &size, ub2 &oracleType, bool readOnly);
122 
123  virtual void pre_use(indicator const *ind);
124  virtual void post_use(bool gotData, indicator *ind);
125 
126  virtual void clean_up();
127 
129 
130  OCIBind *bindp_;
132  void *data_;
133  bool readOnly_;
134  char *buf_; // generic buffer
136 };
137 
139 {
141  : statement_(st), bindp_(NULL), indOCIHolders_(NULL),
142  data_(NULL), buf_(NULL) {}
143 
144  virtual void bind_by_pos(int &position,
145  void *data, details::exchange_type type);
146  virtual void bind_by_name(std::string const &name,
147  void *data, details::exchange_type type);
148 
149  // common part for bind_by_pos and bind_by_name
150  void prepare_for_bind(void *&data, sb4 &size, ub2 &oracleType);
151 
152  // helper function for preparing indicators and sizes_ vectors
153  // (as part of the bind_by_pos and bind_by_name)
154  void prepare_indicators(std::size_t size);
155 
156  virtual void pre_use(indicator const *ind);
157 
158  virtual std::size_t size();
159 
160  virtual void clean_up();
161 
163 
164  OCIBind *bindp_;
165  std::vector<sb2> indOCIHolderVec_;
167  void *data_;
168  char *buf_; // generic buffer
170 
171  // used for strings only
172  std::vector<ub2> sizes_;
173  std::size_t maxSize_;
174 };
175 
178 {
180 
181  virtual void alloc();
182  virtual void clean_up();
183  virtual void prepare(std::string const &query,
185 
186  virtual exec_fetch_result execute(int number);
187  virtual exec_fetch_result fetch(int number);
188 
189  virtual long long get_affected_rows();
190  virtual int get_number_of_rows();
191 
192  virtual std::string rewrite_for_procedure_call(std::string const &query);
193 
194  virtual int prepare_for_describe();
195  virtual void describe_column(int colNum, data_type &dtype,
196  std::string &columnName);
197 
198  // helper for defining into vector<string>
199  std::size_t column_size(int position);
200 
201  virtual oracle_standard_into_type_backend * make_into_type_backend();
202  virtual oracle_standard_use_type_backend * make_use_type_backend();
203  virtual oracle_vector_into_type_backend * make_vector_into_type_backend();
204  virtual oracle_vector_use_type_backend * make_vector_use_type_backend();
205 
207 
208  OCIStmt *stmtp_;
209 
212  bool noData_;
213 };
214 
216 {
218 
220 
221  OCIRowid *rowidp_;
222 };
223 
225 {
227 
229 
230  virtual std::size_t get_len();
231  virtual std::size_t read(std::size_t offset, char *buf,
232  std::size_t toRead);
233  virtual std::size_t write(std::size_t offset, char const *buf,
234  std::size_t toWrite);
235  virtual std::size_t append(char const *buf, std::size_t toWrite);
236  virtual void trim(std::size_t newLen);
237 
239 
240  OCILobLocator *lobp_;
241 };
242 
244 {
245  oracle_session_backend(std::string const & serviceName,
246  std::string const & userName,
247  std::string const & password,
248  int mode,
249  bool decimals_as_strings = false);
250 
252 
253  virtual void begin();
254  virtual void commit();
255  virtual void rollback();
256 
257  virtual std::string get_backend_name() const { return "oracle"; }
258 
259  void clean_up();
260 
261  virtual oracle_statement_backend * make_statement_backend();
262  virtual oracle_rowid_backend * make_rowid_backend();
263  virtual oracle_blob_backend * make_blob_backend();
264 
265  bool get_option_decimals_as_strings() { return decimals_as_strings_; }
266 
267  OCIEnv *envhp_;
268  OCIServer *srvhp_;
269  OCIError *errhp_;
270  OCISvcCtx *svchp_;
271  OCISession *usrhp_;
273 };
274 
276 {
278  virtual oracle_session_backend * make_session(
279  connection_parameters const & parameters) const;
280 };
281 
283 
284 extern "C"
285 {
286 
287 // for dynamic backend loading
290 
291 } // extern "C"
292 
293 } // namespace soci
294 
295 #endif
#define SOCI_ORACLE_DECL
Definition: soci-oracle.h:23
SOCI_ORACLE_DECL oracle_backend_factory const oracle
SOCI_ORACLE_DECL backend_factory const * factory_oracle()
oracle_statement_backend & statement_
Definition: soci-oracle.h:162
virtual std::string get_backend_name() const
Definition: soci-oracle.h:257
details::exchange_type type_
Definition: soci-oracle.h:169
oracle_vector_into_type_backend(oracle_statement_backend &st)
Definition: soci-oracle.h:76
oracle_standard_use_type_backend(oracle_statement_backend &st)
Definition: soci-oracle.h:111
oracle_session_backend & session_
Definition: soci-oracle.h:206
oracle_statement_backend & statement_
Definition: soci-oracle.h:128
oracle_vector_use_type_backend(oracle_statement_backend &st)
Definition: soci-oracle.h:140
oracle_session_backend & session_
Definition: soci-oracle.h:238
SOCI_ORACLE_DECL void register_factory_oracle()
OCILobLocator * lobp_
Definition: soci-oracle.h:240
std::vector< ISM::CombinatorialTrainerParameters > parameters
oracle_standard_into_type_backend(oracle_statement_backend &st)
Definition: soci-oracle.h:50
oracle_statement_backend & statement_
Definition: soci-oracle.h:95
oracle_statement_backend & statement_
Definition: soci-oracle.h:63


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:41