Oracle ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
oracle-types.hxx
Go to the documentation of this file.
1 // file : odb/oracle/oracle-types.hxx
2 // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
3 // license : ODB NCUEL; see accompanying LICENSE file
4 
5 #ifndef ODB_ORACLE_ORACLE_TYPES_HXX
6 #define ODB_ORACLE_ORACLE_TYPES_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <odb/details/buffer.hxx>
11 
12 #include <odb/oracle/version.hxx>
13 #include <odb/oracle/forward.hxx> // binding
15 
16 #include <odb/oracle/details/export.hxx>
17 
18 namespace odb
19 {
20  namespace oracle
21  {
23  {
28  };
29 
30  // Callback function signature used to specify LOB parameters that are
31  // passed to the database. If false is returned from the callback,
32  // statement execution is aborted.
33  //
34  typedef bool (*param_callback_type) (
35  const void* context, // [in] The user context.
36  ub4* position_context, // [in] A position context. A callback is free to
37  // use this to track position information. This is
38  // initialized to zero before the callback is
39  // invoked for the first time.
40  const void** buffer, // [out] On return, a pointer to a buffer
41  // containing parameter data.
42  ub4* size, // [out] The parameter data size in bytes.
43  chunk_position*, // [out] The position of the chunk of data in
44  // buffer.
45  void* temp_buffer, // [in] A temporary buffer that may be used if
46  // required. The buffer argument should specify
47  // this buffer on return if it is used.
48  ub4 capacity); // [in] The temporary buffer size in bytes.
49 
50  // Callback function signature used to specify LOB values returned from
51  // the database. If false is returned, database_exception is thrown.
52  //
53  typedef bool (*result_callback_type) (
54  void* context, // [in] The user context.
55  ub4* position_context, // [in] A position context. A callback is free to
56  // use this to track position information. This is
57  // initialized to zero before the callback is
58  // invoked for the first time.
59  void* buffer, // [in] A buffer containing the result data.
60  ub4 size, // [in] The result data size in bytes.
61  chunk_position); // [in] The position of this chunk.
62 
63  struct lob_callback
64  {
65  union
66  {
69  } callback;
70 
71  union
72  {
73  const void* param;
74  void* result;
75  } context;
76  };
77 
78  struct bind
79  {
80  // This enumeration identifies the possible buffer types that can be
81  // bound to a bind instance. In most cases, these map directly to
82  // SQLT_XXX codes, identifying an external OCI type. nstring and nclob
83  // however have no equivalent OCI typecode. These additional identifiers
84  // allow for a consistent interface across all types. Note that these
85  // values are mapped to their corresponding external OCI typecodes (if
86  // any) using their integer values, and should therefore not be
87  // rearranged or explicitly assigned without also adjusting the
88  // sqlt_lookup array in odb/oracle/statement.cxx.
89  //
91  {
92  integer, // Buffer is an integer type of size specified by size.
93  uinteger, // Buffer is an unsigned integer of size specified by
94  // size.
95  binary_float, // Buffer is a float.
96  binary_double, // Buffer is a double.
97  number, // Buffer is a variable length char array.
98  date, // Buffer is a 7-byte char array.
99  timestamp, // Buffer is a datetime.
100  interval_ym, // Buffer is an interval_ym.
101  interval_ds, // Buffer is an interval_ds.
102  string, // Buffer is a variable length char array.
103  nstring, // Buffer is a variable length char array.
104  raw, // Buffer is a variable length char array.
105  blob, // Bind is a callback.
106  clob, // Bind is a callback.
107  nclob, // Bind is a callback.
108  last // Used as an end of list marker.
109  };
110 
111  buffer_type type; // The type stored by buffer.
112  void* buffer; // Data buffer pointer. For LOB type bindings, this is
113  // interpreted as an oracle::lob*.
114  ub2* size; // The number of bytes in buffer. For LOB result
115  // bindings, this is interpreted as the OCIDefine
116  // handle associated with the LOB result parameter.
117  ub4 capacity; // The maximum number of bytes that can be stored in
118  // the buffer.
119  sb2* indicator; // Pointer to an OCI indicator variable.
120 
122  };
123 
124  // An instance of this structure specifies the function to invoke and
125  // the context to pass when the object/view image is about to be
126  // modified. This mechanism is used by the query machinery to save the
127  // image between result iteration and dereferencing if something gets
128  // executed between these two operations that would overwrite the
129  // image.
130  //
132  {
134 
135  void (*callback) (void*, binding*);
136  void* context;
137  };
138 
139  // The lob structure wraps data required for both parameter and result
140  // LOB type bindings.
141  //
142  struct LIBODB_ORACLE_EXPORT lob
143  {
144  lob (): locator (0), buffer (0), position (0) {}
145 
146  lob (lob&);
147  lob& operator= (lob&);
148 
149  ~lob ();
150 
151  public:
153  details::buffer* buffer;
155  };
156 
157  //
158  // The OCIDateTime and OCIInterval APIs require that an environment and
159  // error handle be passed to any function that manipulates an OCIDateTime
160  // or OCIInterval descriptor. It is however impossible to obtain these
161  // handles at the time a temporal data image is first initialized. The
162  // following structures allow ODB generated code to interact with the OCI
163  // temporal descriptor types indirectly via C++ primitives. The wrapped OCI
164  // descriptor is then set using these primitives at a time when the
165  // required data is available. A symmetric get interface is provided for
166  // consistency.
167  //
168 
169  // Descriptor management flags.
170  //
171  const unsigned short descriptor_cache = 0x01;
172  const unsigned short descriptor_free = 0x02;
173 
174  struct LIBODB_ORACLE_EXPORT datetime
175  {
176  void
177  get (sb2& year,
178  ub1& month,
179  ub1& day,
180  ub1& hour,
181  ub1& minute,
182  ub1& second,
183  ub4& nanosecond) const;
184 
185  void
186  set (sb2 year,
187  ub1 month,
188  ub1 day,
189  ub1 hour,
190  ub1 minute,
191  ub1 second,
192  ub4 nanosecond);
193 
194  public:
198 
199  unsigned short flags;
200 
201  public:
203  : descriptor (0), flags (f)
204  {
205  }
206 
207  datetime (datetime&);
208  datetime& operator= (datetime&);
209 
210  ~datetime ();
211 
212  public:
220  };
221 
222  struct LIBODB_ORACLE_EXPORT interval_ym
223  {
224  void
225  get (sb4& year, sb4& month) const;
226 
227  void
228  set (sb4 year, sb4 month);
229 
230  public:
234 
235  unsigned short flags;
236 
237  public:
239  : descriptor (0), flags (f)
240  {
241  }
242 
244  interval_ym& operator= (interval_ym&);
245 
246  ~interval_ym ();
247 
248  public:
251  };
252 
253  struct LIBODB_ORACLE_EXPORT interval_ds
254  {
255  void
256  get (sb4& day,
257  sb4& hour,
258  sb4& minute,
259  sb4& second,
260  sb4& nanosecond) const;
261 
262  void
263  set (sb4 day,
264  sb4 hour,
265  sb4 minute,
266  sb4 second,
267  sb4 nanosecond);
268 
269  public:
273 
274  unsigned short flags;
275 
276  public:
278  : descriptor (0), flags (f)
279  {
280  }
281 
283  interval_ds& operator= (interval_ds&);
284 
285  ~interval_ds ();
286 
287  public:
293  };
294  }
295 }
296 
297 #include <odb/post.hxx>
298 
299 #endif // ODB_ORACLE_ORACLE_TYPES_HXX
Definition: oracle-types.hxx:92
OCILobLocator * locator
Definition: oracle-types.hxx:152
ub2 * size
Definition: oracle-types.hxx:114
OCIEnv * environment
Definition: oracle-types.hxx:231
Definition: oracle-types.hxx:63
buffer_type
Definition: oracle-types.hxx:90
bool(* result_callback_type)(void *context, ub4 *position_context, void *buffer, ub4 size, chunk_position)
Definition: oracle-types.hxx:53
param_callback_type param
Definition: oracle-types.hxx:67
Definition: oracle-types.hxx:106
OCIError * error
Definition: oracle-types.hxx:232
datetime(unsigned short f=descriptor_cache|descriptor_free)
Definition: oracle-types.hxx:202
unsigned short flags
Definition: oracle-types.hxx:274
chunk_position
Definition: oracle-types.hxx:22
struct OCIDateTime OCIDateTime
Definition: oracle-fwd.hxx:31
Definition: oracle-types.hxx:102
void * context
Definition: oracle-types.hxx:136
OCIError * error
Definition: oracle-types.hxx:196
Definition: oracle-types.hxx:24
Definition: oracle-types.hxx:103
Definition: oracle-types.hxx:93
details::buffer * buffer
Definition: oracle-types.hxx:153
ub1 day_
Definition: oracle-types.hxx:215
ub4 nanosecond_
Definition: oracle-types.hxx:219
unsigned short flags
Definition: oracle-types.hxx:235
Definition: oracle-types.hxx:142
unsigned int ub4
Definition: oracle-fwd.hxx:20
buffer_type type
Definition: oracle-types.hxx:111
void(* callback)(void *, binding *)
Definition: oracle-types.hxx:135
Definition: oracle-types.hxx:98
ub1 hour_
Definition: oracle-types.hxx:216
lob_callback * callback
Definition: oracle-types.hxx:121
Definition: oracle-types.hxx:96
const void * param
Definition: oracle-types.hxx:73
const unsigned short descriptor_cache
Definition: oracle-types.hxx:171
Definition: oracle-types.hxx:27
void * buffer
Definition: oracle-types.hxx:112
OCIError * error
Definition: oracle-types.hxx:271
const unsigned short descriptor_free
Definition: oracle-types.hxx:172
Definition: oracle-types.hxx:95
Definition: binding.hxx:21
ub1 second_
Definition: oracle-types.hxx:218
change_callback()
Definition: oracle-types.hxx:133
struct OCIError OCIError
Definition: oracle-fwd.hxx:24
ub1 month_
Definition: oracle-types.hxx:214
sb4 hour_
Definition: oracle-types.hxx:289
ub4 position
Definition: oracle-types.hxx:154
Definition: oracle-types.hxx:26
struct OCILobLocator OCILobLocator
Definition: oracle-fwd.hxx:30
Definition: oracle-types.hxx:108
struct OCIInterval OCIInterval
Definition: oracle-fwd.hxx:32
Definition: oracle-types.hxx:99
sb4 second_
Definition: oracle-types.hxx:291
Definition: oracle-types.hxx:78
Definition: oracle-types.hxx:174
ub1 minute_
Definition: oracle-types.hxx:217
sb4 nanosecond_
Definition: oracle-types.hxx:292
sb4 minute_
Definition: oracle-types.hxx:290
unsigned short ub2
Definition: oracle-fwd.hxx:18
void * result
Definition: oracle-types.hxx:74
interval_ym(unsigned short f=descriptor_cache|descriptor_free)
Definition: oracle-types.hxx:238
sb2 * indicator
Definition: oracle-types.hxx:119
ub4 capacity
Definition: oracle-types.hxx:117
union odb::oracle::lob_callback::@0 callback
Definition: oracle-types.hxx:253
Definition: oracle-types.hxx:97
OCIEnv * environment
Definition: oracle-types.hxx:270
Definition: oracle-types.hxx:101
Definition: oracle-types.hxx:222
interval_ds(unsigned short f=descriptor_cache|descriptor_free)
Definition: oracle-types.hxx:277
sb4 year_
Definition: oracle-types.hxx:249
signed short sb2
Definition: oracle-fwd.hxx:17
Definition: oracle-types.hxx:105
unsigned char ub1
Definition: oracle-fwd.hxx:15
Definition: oracle-types.hxx:100
Definition: oracle-types.hxx:25
OCIInterval * descriptor
Definition: oracle-types.hxx:233
struct OCIEnv OCIEnv
Definition: oracle-fwd.hxx:22
OCIEnv * environment
Definition: oracle-types.hxx:195
Definition: oracle-types.hxx:107
OCIInterval * descriptor
Definition: oracle-types.hxx:272
Definition: oracle-types.hxx:104
sb4 day_
Definition: oracle-types.hxx:288
sb2 year_
Definition: oracle-types.hxx:213
bool(* param_callback_type)(const void *context, ub4 *position_context, const void **buffer, ub4 *size, chunk_position *, void *temp_buffer, ub4 capacity)
Definition: oracle-types.hxx:34
Definition: oracle-types.hxx:131
sb4 month_
Definition: oracle-types.hxx:250
OCIDateTime * descriptor
Definition: oracle-types.hxx:197
lob()
Definition: oracle-types.hxx:144
union odb::oracle::lob_callback::@1 context
signed int sb4
Definition: oracle-fwd.hxx:19
result_callback_type result
Definition: oracle-types.hxx:68
unsigned short flags
Definition: oracle-types.hxx:199