ruby-oci8 1.0.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1254 -390
- data/Makefile +10 -13
- data/README +56 -385
- data/VERSION +1 -1
- data/dist-files +26 -27
- data/ext/oci8/.document +1 -0
- data/ext/oci8/MANIFEST +0 -4
- data/ext/oci8/apiwrap.c.tmpl +172 -0
- data/ext/oci8/apiwrap.h.tmpl +61 -0
- data/ext/oci8/apiwrap.rb +91 -0
- data/ext/oci8/apiwrap.yml +1243 -0
- data/ext/oci8/attr.c +124 -384
- data/ext/oci8/bind.c +472 -164
- data/ext/oci8/encoding.c +196 -0
- data/ext/oci8/env.c +84 -253
- data/ext/oci8/error.c +196 -127
- data/ext/oci8/extconf.rb +82 -59
- data/ext/oci8/lob.c +710 -370
- data/ext/oci8/metadata.c +359 -0
- data/ext/oci8/object.c +622 -0
- data/ext/oci8/oci8.c +577 -161
- data/ext/oci8/oci8.h +354 -258
- data/ext/oci8/oci8lib.c +493 -0
- data/ext/oci8/ocidatetime.c +473 -0
- data/ext/oci8/ocinumber.c +1123 -24
- data/ext/oci8/oraconf.rb +72 -106
- data/ext/oci8/oradate.c +511 -321
- data/ext/oci8/stmt.c +752 -572
- data/ext/oci8/win32.c +131 -0
- data/ext/oci8/xmldb.c +383 -0
- data/lib/.document +2 -0
- data/lib/dbd/OCI8.rb +2 -17
- data/lib/oci8.rb.in +41 -1622
- data/lib/oci8/.document +5 -0
- data/lib/oci8/compat.rb +108 -0
- data/lib/oci8/datetime.rb +489 -0
- data/lib/oci8/encoding-init.rb +40 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2077 -0
- data/lib/oci8/object.rb +548 -0
- data/lib/oci8/oci8.rb +773 -0
- data/lib/oci8/oracle_version.rb +144 -0
- data/metaconfig +3 -3
- data/ruby-oci8.gemspec +5 -5
- data/setup.rb +4 -4
- data/test/config.rb +64 -84
- data/test/test_all.rb +14 -21
- data/test/test_array_dml.rb +317 -0
- data/test/test_bind_raw.rb +18 -25
- data/test/test_bind_time.rb +78 -91
- data/test/test_break.rb +37 -35
- data/test/test_clob.rb +33 -89
- data/test/test_connstr.rb +5 -4
- data/test/test_datetime.rb +469 -0
- data/test/test_dbi.rb +99 -60
- data/test/test_dbi_clob.rb +3 -8
- data/test/test_metadata.rb +65 -51
- data/test/test_oci8.rb +151 -55
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +76 -83
- data/test/test_oranumber.rb +405 -71
- data/test/test_rowid.rb +6 -11
- metadata +31 -32
- data/NEWS +0 -420
- data/ext/oci8/const.c +0 -165
- data/ext/oci8/define.c +0 -53
- data/ext/oci8/describe.c +0 -81
- data/ext/oci8/descriptor.c +0 -39
- data/ext/oci8/handle.c +0 -273
- data/ext/oci8/oranumber.c +0 -445
- data/ext/oci8/param.c +0 -37
- data/ext/oci8/server.c +0 -182
- data/ext/oci8/session.c +0 -99
- data/ext/oci8/svcctx.c +0 -238
- data/ruby-oci8.spec +0 -62
- data/support/README +0 -4
- data/support/runit/assert.rb +0 -281
- data/support/runit/cui/testrunner.rb +0 -101
- data/support/runit/error.rb +0 -4
- data/support/runit/method_mappable.rb +0 -20
- data/support/runit/robserver.rb +0 -25
- data/support/runit/setuppable.rb +0 -15
- data/support/runit/teardownable.rb +0 -16
- data/support/runit/testcase.rb +0 -113
- data/support/runit/testfailure.rb +0 -25
- data/support/runit/testresult.rb +0 -121
- data/support/runit/testsuite.rb +0 -43
- data/support/runit/version.rb +0 -3
- data/test/test_describe.rb +0 -137
@@ -0,0 +1,473 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* ocidatetime.c
|
4
|
+
*
|
5
|
+
* $Author: kubo $
|
6
|
+
* $Date: 2008-09-10 23:07:07 +0900 (Wed, 10 Sep 2008) $
|
7
|
+
*
|
8
|
+
* Copyright (C) 2005-2008 KUBO Takehiro <kubo@jiubao.org>
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
#include "oci8.h"
|
12
|
+
|
13
|
+
VALUE oci8_make_ocidate(OCIDate *od)
|
14
|
+
{
|
15
|
+
return rb_ary_new3(6,
|
16
|
+
INT2FIX(od->OCIDateYYYY),
|
17
|
+
INT2FIX(od->OCIDateMM),
|
18
|
+
INT2FIX(od->OCIDateDD),
|
19
|
+
INT2FIX(od->OCIDateTime.OCITimeHH),
|
20
|
+
INT2FIX(od->OCIDateTime.OCITimeMI),
|
21
|
+
INT2FIX(od->OCIDateTime.OCITimeSS));
|
22
|
+
}
|
23
|
+
|
24
|
+
OCIDate *oci8_set_ocidate(OCIDate *od, VALUE val)
|
25
|
+
{
|
26
|
+
long year, month, day, hour, minute, second;
|
27
|
+
|
28
|
+
Check_Type(val, T_ARRAY);
|
29
|
+
if (RARRAY_LEN(val) != 6) {
|
30
|
+
rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
|
31
|
+
}
|
32
|
+
/* year */
|
33
|
+
year = NUM2LONG(RARRAY_PTR(val)[0]);
|
34
|
+
if (year < -4712 || 9999 < year) {
|
35
|
+
rb_raise(rb_eRuntimeError, "out of year range: %ld", year);
|
36
|
+
}
|
37
|
+
od->OCIDateYYYY = (sb2)year;
|
38
|
+
/* month */
|
39
|
+
month = NUM2LONG(RARRAY_PTR(val)[1]);
|
40
|
+
if (month < 0 || 12 < month) {
|
41
|
+
rb_raise(rb_eRuntimeError, "out of month range: %ld", month);
|
42
|
+
}
|
43
|
+
od->OCIDateMM = (ub1)month;
|
44
|
+
/* day */
|
45
|
+
day = NUM2LONG(RARRAY_PTR(val)[2]);
|
46
|
+
if (day < 0 || 31 < day) {
|
47
|
+
rb_raise(rb_eRuntimeError, "out of day range: %ld", day);
|
48
|
+
}
|
49
|
+
od->OCIDateDD = (ub1)day;
|
50
|
+
/* hour */
|
51
|
+
hour = NUM2LONG(RARRAY_PTR(val)[3]);
|
52
|
+
if (hour < 0 || 23 < hour) {
|
53
|
+
rb_raise(rb_eRuntimeError, "out of hour range: %ld", hour);
|
54
|
+
}
|
55
|
+
od->OCIDateTime.OCITimeHH = (ub1)hour;
|
56
|
+
/* minute */
|
57
|
+
minute = NUM2LONG(RARRAY_PTR(val)[4]);
|
58
|
+
if (minute < 0 || 59 < minute) {
|
59
|
+
rb_raise(rb_eRuntimeError, "out of minute range: %ld", minute);
|
60
|
+
}
|
61
|
+
od->OCIDateTime.OCITimeMI = (ub1)minute;
|
62
|
+
/* second */
|
63
|
+
second = NUM2LONG(RARRAY_PTR(val)[5]);
|
64
|
+
if (second < 0 || 59 < second) {
|
65
|
+
rb_raise(rb_eRuntimeError, "out of second range: %ld", second);
|
66
|
+
}
|
67
|
+
od->OCIDateTime.OCITimeSS = (ub1)second;
|
68
|
+
return od;
|
69
|
+
}
|
70
|
+
|
71
|
+
static VALUE bind_ocidate_get(oci8_bind_t *obind, void *data, void *null_struct)
|
72
|
+
{
|
73
|
+
return oci8_make_ocidate((OCIDate *)data);
|
74
|
+
}
|
75
|
+
|
76
|
+
static void bind_ocidate_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
|
77
|
+
{
|
78
|
+
oci8_set_ocidate((OCIDate *)data, val);
|
79
|
+
}
|
80
|
+
|
81
|
+
static void bind_ocidate_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
|
82
|
+
{
|
83
|
+
obind->value_sz = sizeof(OCIDate);
|
84
|
+
obind->alloc_sz = sizeof(OCIDate);
|
85
|
+
}
|
86
|
+
|
87
|
+
static const oci8_bind_class_t bind_ocidate_class = {
|
88
|
+
{
|
89
|
+
NULL,
|
90
|
+
oci8_bind_free,
|
91
|
+
sizeof(oci8_bind_t)
|
92
|
+
},
|
93
|
+
bind_ocidate_get,
|
94
|
+
bind_ocidate_set,
|
95
|
+
bind_ocidate_init,
|
96
|
+
NULL,
|
97
|
+
NULL,
|
98
|
+
NULL,
|
99
|
+
NULL,
|
100
|
+
SQLT_ODT,
|
101
|
+
};
|
102
|
+
|
103
|
+
#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0
|
104
|
+
|
105
|
+
VALUE oci8_make_ocitimestamp(OCIDateTime *dttm)
|
106
|
+
{
|
107
|
+
sb2 year;
|
108
|
+
ub1 month;
|
109
|
+
ub1 day;
|
110
|
+
ub1 hour;
|
111
|
+
ub1 minute;
|
112
|
+
ub1 sec;
|
113
|
+
ub4 fsec;
|
114
|
+
sb1 tz_hour;
|
115
|
+
sb1 tz_minute;
|
116
|
+
sword rv;
|
117
|
+
int have_tz;
|
118
|
+
|
119
|
+
oci_lc(OCIDateTimeGetDate(oci8_envhp, oci8_errhp, dttm, &year, &month, &day));
|
120
|
+
oci_lc(OCIDateTimeGetTime(oci8_envhp, oci8_errhp, dttm, &hour, &minute, &sec, &fsec));
|
121
|
+
rv = OCIDateTimeGetTimeZoneOffset(oci8_envhp, oci8_errhp, dttm, &tz_hour, &tz_minute);
|
122
|
+
have_tz = (rv == OCI_SUCCESS);
|
123
|
+
return rb_ary_new3(9,
|
124
|
+
INT2FIX(year),
|
125
|
+
INT2FIX(month),
|
126
|
+
INT2FIX(day),
|
127
|
+
INT2FIX(hour),
|
128
|
+
INT2FIX(minute),
|
129
|
+
INT2FIX(sec),
|
130
|
+
INT2FIX(fsec),
|
131
|
+
have_tz ? INT2FIX(tz_hour) : Qnil,
|
132
|
+
have_tz ? INT2FIX(tz_minute) : Qnil);
|
133
|
+
}
|
134
|
+
|
135
|
+
OCIDateTime *oci8_set_ocitimestamp(OCIDateTime *dttm, VALUE val, VALUE svc)
|
136
|
+
{
|
137
|
+
long year;
|
138
|
+
long month;
|
139
|
+
long day;
|
140
|
+
long hour;
|
141
|
+
long minute;
|
142
|
+
long sec;
|
143
|
+
long fsec;
|
144
|
+
OraText *tz;
|
145
|
+
size_t tzlen;
|
146
|
+
char tz_str[32];
|
147
|
+
OCISession *seshp = NULL;
|
148
|
+
|
149
|
+
Check_Type(val, T_ARRAY);
|
150
|
+
if (RARRAY_LEN(val) != 9) {
|
151
|
+
rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
|
152
|
+
}
|
153
|
+
/* year */
|
154
|
+
year = NUM2LONG(RARRAY_PTR(val)[0]);
|
155
|
+
if (year < -4712 || 9999 < year) {
|
156
|
+
rb_raise(rb_eRuntimeError, "out of year range: %ld", year);
|
157
|
+
}
|
158
|
+
/* month */
|
159
|
+
month = NUM2LONG(RARRAY_PTR(val)[1]);
|
160
|
+
if (month < 0 || 12 < month) {
|
161
|
+
rb_raise(rb_eRuntimeError, "out of month range: %ld", month);
|
162
|
+
}
|
163
|
+
/* day */
|
164
|
+
day = NUM2LONG(RARRAY_PTR(val)[2]);
|
165
|
+
if (day < 0 || 31 < day) {
|
166
|
+
rb_raise(rb_eRuntimeError, "out of day range: %ld", day);
|
167
|
+
}
|
168
|
+
/* hour */
|
169
|
+
hour = NUM2LONG(RARRAY_PTR(val)[3]);
|
170
|
+
if (hour < 0 || 23 < hour) {
|
171
|
+
rb_raise(rb_eRuntimeError, "out of hour range: %ld", hour);
|
172
|
+
}
|
173
|
+
/* minute */
|
174
|
+
minute = NUM2LONG(RARRAY_PTR(val)[4]);
|
175
|
+
if (minute < 0 || 60 < minute) {
|
176
|
+
rb_raise(rb_eRuntimeError, "out of minute range: %ld", minute);
|
177
|
+
}
|
178
|
+
/* second */
|
179
|
+
sec = NUM2LONG(RARRAY_PTR(val)[5]);
|
180
|
+
if (sec < 0 || 60 < sec) {
|
181
|
+
rb_raise(rb_eRuntimeError, "out of second range: %ld", sec);
|
182
|
+
}
|
183
|
+
/* sec_fraction */
|
184
|
+
fsec = NUM2LONG(RARRAY_PTR(val)[6]);
|
185
|
+
if (fsec < 0 || 1000000000 < fsec) {
|
186
|
+
rb_raise(rb_eRuntimeError, "out of sec_fraction range: %ld", fsec);
|
187
|
+
}
|
188
|
+
/* time zone */
|
189
|
+
if (NIL_P(RARRAY_PTR(val)[7]) && NIL_P(RARRAY_PTR(val)[8])) {
|
190
|
+
if (!NIL_P(svc)) {
|
191
|
+
/* use session timezone. */
|
192
|
+
seshp = oci8_get_oci_session(svc);
|
193
|
+
}
|
194
|
+
tz = NULL;
|
195
|
+
tzlen = 0;
|
196
|
+
} else {
|
197
|
+
snprintf(tz_str, sizeof(tz_str), "%+02ld:%02ld",
|
198
|
+
NUM2LONG(RARRAY_PTR(val)[7]),
|
199
|
+
NUM2LONG(RARRAY_PTR(val)[8]));
|
200
|
+
tz_str[sizeof(tz_str) - 1] = '\0';
|
201
|
+
tz = (OraText*)tz_str;
|
202
|
+
tzlen = strlen(tz_str);
|
203
|
+
}
|
204
|
+
/* construct */
|
205
|
+
oci_lc(OCIDateTimeConstruct(seshp ? (void*)seshp : (void*)oci8_envhp, oci8_errhp, dttm,
|
206
|
+
(sb2)year,
|
207
|
+
(ub1)month,
|
208
|
+
(ub1)day,
|
209
|
+
(ub1)hour,
|
210
|
+
(ub1)minute,
|
211
|
+
(ub1)sec,
|
212
|
+
(ub4)fsec,
|
213
|
+
tz, tzlen));
|
214
|
+
return dttm;
|
215
|
+
}
|
216
|
+
|
217
|
+
typedef struct {
|
218
|
+
oci8_bind_t obind;
|
219
|
+
ub4 type;
|
220
|
+
} oci8_bind_dsc_t;
|
221
|
+
|
222
|
+
static void oci8_bind_dsc_free(oci8_base_t *base)
|
223
|
+
{
|
224
|
+
oci8_bind_t *obind = (oci8_bind_t *)base;
|
225
|
+
ub4 type = ((oci8_bind_dsc_t *)base)->type;
|
226
|
+
if (obind->valuep != NULL) {
|
227
|
+
ub4 idx = 0;
|
228
|
+
void **pp = (void**)obind->valuep;
|
229
|
+
|
230
|
+
do {
|
231
|
+
if (pp[idx] != NULL) {
|
232
|
+
OCIDescriptorFree(pp[idx], type);
|
233
|
+
pp[idx] = NULL;
|
234
|
+
}
|
235
|
+
} while (++idx < obind->maxar_sz);
|
236
|
+
}
|
237
|
+
oci8_bind_free(base);
|
238
|
+
}
|
239
|
+
|
240
|
+
static VALUE bind_ocitimestamp_get(oci8_bind_t *obind, void *data, void *null_struct)
|
241
|
+
{
|
242
|
+
return oci8_make_ocitimestamp(*(OCIDateTime **)data);
|
243
|
+
}
|
244
|
+
|
245
|
+
static void bind_ocitimestamp_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
|
246
|
+
{
|
247
|
+
oci8_base_t *stmt;
|
248
|
+
oci8_base_t *svcctx;
|
249
|
+
|
250
|
+
stmt = obind->base.parent;
|
251
|
+
if (stmt == NULL || stmt->type != OCI_HTYPE_STMT) {
|
252
|
+
rb_raise(rb_eRuntimeError, "oci8lib.so internal error [%s:%d, %p, %d]",
|
253
|
+
__FILE__, __LINE__,
|
254
|
+
stmt, stmt ? stmt->type : -1);
|
255
|
+
}
|
256
|
+
svcctx = stmt->parent;
|
257
|
+
if (svcctx == NULL || svcctx->type != OCI_HTYPE_SVCCTX) {
|
258
|
+
rb_raise(rb_eRuntimeError, "oci8lib.so internal error [%s:%d, %p, %d]",
|
259
|
+
__FILE__, __LINE__,
|
260
|
+
svcctx, svcctx ? svcctx->type : -1);
|
261
|
+
}
|
262
|
+
oci8_set_ocitimestamp(*(OCIDateTime **)data, val, svcctx->self);
|
263
|
+
}
|
264
|
+
|
265
|
+
static void bind_ocitimestamp_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
|
266
|
+
{
|
267
|
+
oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind;
|
268
|
+
|
269
|
+
obind->value_sz = sizeof(OCIDateTime *);
|
270
|
+
obind->alloc_sz = sizeof(OCIDateTime *);
|
271
|
+
obind_dsc->type = OCI_DTYPE_TIMESTAMP_TZ;
|
272
|
+
}
|
273
|
+
|
274
|
+
static void bind_ocitimestamp_init_elem(oci8_bind_t *obind, VALUE svc)
|
275
|
+
{
|
276
|
+
ub4 idx = 0;
|
277
|
+
sword rv;
|
278
|
+
|
279
|
+
do {
|
280
|
+
rv = OCIDescriptorAlloc(oci8_envhp, (dvoid*)((OCIDateTime**)obind->valuep + idx), OCI_DTYPE_TIMESTAMP_TZ, 0, 0);
|
281
|
+
if (rv != OCI_SUCCESS)
|
282
|
+
oci8_env_raise(oci8_envhp, rv);
|
283
|
+
} while (++idx < obind->maxar_sz);
|
284
|
+
}
|
285
|
+
|
286
|
+
static const oci8_bind_class_t bind_ocitimestamp_class = {
|
287
|
+
{
|
288
|
+
NULL,
|
289
|
+
oci8_bind_dsc_free,
|
290
|
+
sizeof(oci8_bind_dsc_t)
|
291
|
+
},
|
292
|
+
bind_ocitimestamp_get,
|
293
|
+
bind_ocitimestamp_set,
|
294
|
+
bind_ocitimestamp_init,
|
295
|
+
bind_ocitimestamp_init_elem,
|
296
|
+
NULL,
|
297
|
+
NULL,
|
298
|
+
NULL,
|
299
|
+
SQLT_TIMESTAMP_TZ
|
300
|
+
};
|
301
|
+
|
302
|
+
VALUE oci8_make_ociinterval_ym(OCIInterval *s)
|
303
|
+
{
|
304
|
+
sb4 year;
|
305
|
+
sb4 month;
|
306
|
+
|
307
|
+
oci_lc(OCIIntervalGetYearMonth(oci8_envhp, oci8_errhp, &year, &month, s));
|
308
|
+
return rb_ary_new3(2, INT2FIX(year), INT2FIX(month));
|
309
|
+
}
|
310
|
+
|
311
|
+
OCIInterval *oci8_set_ociinterval_ym(OCIInterval *intvl, VALUE val)
|
312
|
+
{
|
313
|
+
sb4 year;
|
314
|
+
sb4 month;
|
315
|
+
|
316
|
+
Check_Type(val, T_ARRAY);
|
317
|
+
if (RARRAY_LEN(val) != 2) {
|
318
|
+
rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
|
319
|
+
}
|
320
|
+
year = NUM2INT(RARRAY_PTR(val)[0]);
|
321
|
+
month = NUM2INT(RARRAY_PTR(val)[1]);
|
322
|
+
oci_lc(OCIIntervalSetYearMonth(oci8_envhp, oci8_errhp,
|
323
|
+
year, month, intvl));
|
324
|
+
return intvl;
|
325
|
+
}
|
326
|
+
|
327
|
+
VALUE oci8_make_ociinterval_ds(OCIInterval *s)
|
328
|
+
{
|
329
|
+
sb4 day;
|
330
|
+
sb4 hour;
|
331
|
+
sb4 minute;
|
332
|
+
sb4 sec;
|
333
|
+
sb4 fsec;
|
334
|
+
|
335
|
+
oci_lc(OCIIntervalGetDaySecond(oci8_envhp, oci8_errhp, &day, &hour, &minute, &sec, &fsec, s));
|
336
|
+
return rb_ary_new3(5,
|
337
|
+
INT2FIX(day), INT2FIX(hour),
|
338
|
+
INT2FIX(minute), INT2FIX(sec),
|
339
|
+
INT2FIX(fsec));
|
340
|
+
}
|
341
|
+
|
342
|
+
OCIInterval *oci8_set_ociinterval_ds(OCIInterval *intvl, VALUE val)
|
343
|
+
{
|
344
|
+
sb4 day;
|
345
|
+
sb4 hour;
|
346
|
+
sb4 minute;
|
347
|
+
sb4 sec;
|
348
|
+
sb4 fsec;
|
349
|
+
|
350
|
+
Check_Type(val, T_ARRAY);
|
351
|
+
if (RARRAY_LEN(val) != 5) {
|
352
|
+
rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
|
353
|
+
}
|
354
|
+
day = NUM2INT(RARRAY_PTR(val)[0]);
|
355
|
+
hour = NUM2INT(RARRAY_PTR(val)[1]);
|
356
|
+
minute = NUM2INT(RARRAY_PTR(val)[2]);
|
357
|
+
sec = NUM2INT(RARRAY_PTR(val)[3]);
|
358
|
+
fsec = NUM2INT(RARRAY_PTR(val)[4]);
|
359
|
+
oci_lc(OCIIntervalSetDaySecond(oci8_envhp, oci8_errhp,
|
360
|
+
day, hour, minute, sec, fsec, intvl));
|
361
|
+
return intvl;
|
362
|
+
}
|
363
|
+
|
364
|
+
|
365
|
+
static VALUE bind_ociinterval_ym_get(oci8_bind_t *obind, void *data, void *null_struct)
|
366
|
+
{
|
367
|
+
return oci8_make_ociinterval_ym(*(OCIInterval **)data);
|
368
|
+
}
|
369
|
+
|
370
|
+
static void bind_ociinterval_ym_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
|
371
|
+
{
|
372
|
+
oci8_set_ociinterval_ym(*(OCIInterval **)data, val);
|
373
|
+
}
|
374
|
+
|
375
|
+
static void bind_ociinterval_ym_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
|
376
|
+
{
|
377
|
+
oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind;
|
378
|
+
|
379
|
+
obind->value_sz = sizeof(OCIInterval*);
|
380
|
+
obind->alloc_sz = sizeof(OCIInterval*);
|
381
|
+
obind_dsc->type = OCI_DTYPE_INTERVAL_YM;
|
382
|
+
}
|
383
|
+
|
384
|
+
static void bind_ociinterval_ym_init_elem(oci8_bind_t *obind, VALUE svc)
|
385
|
+
{
|
386
|
+
ub4 idx = 0;
|
387
|
+
sword rv;
|
388
|
+
|
389
|
+
do {
|
390
|
+
rv = OCIDescriptorAlloc(oci8_envhp, (dvoid*)((OCIDateTime**)obind->valuep + idx), OCI_DTYPE_INTERVAL_YM, 0, 0);
|
391
|
+
if (rv != OCI_SUCCESS)
|
392
|
+
oci8_env_raise(oci8_envhp, rv);
|
393
|
+
} while (++idx < obind->maxar_sz);
|
394
|
+
}
|
395
|
+
|
396
|
+
static VALUE bind_ociinterval_ds_get(oci8_bind_t *obind, void *data, void *null_struct)
|
397
|
+
{
|
398
|
+
return oci8_make_ociinterval_ds(*(OCIInterval **)data);
|
399
|
+
}
|
400
|
+
|
401
|
+
static void bind_ociinterval_ds_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
|
402
|
+
{
|
403
|
+
oci8_set_ociinterval_ds(*(OCIInterval **)data, val);
|
404
|
+
}
|
405
|
+
|
406
|
+
static void bind_ociinterval_ds_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
|
407
|
+
{
|
408
|
+
oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind;
|
409
|
+
|
410
|
+
obind->value_sz = sizeof(OCIInterval *);
|
411
|
+
obind->alloc_sz = sizeof(OCIInterval *);
|
412
|
+
obind_dsc->type = OCI_DTYPE_INTERVAL_DS;
|
413
|
+
}
|
414
|
+
|
415
|
+
static void bind_ociinterval_ds_init_elem(oci8_bind_t *obind, VALUE svc)
|
416
|
+
{
|
417
|
+
ub4 idx = 0;
|
418
|
+
sword rv;
|
419
|
+
|
420
|
+
do {
|
421
|
+
rv = OCIDescriptorAlloc(oci8_envhp, (dvoid*)((OCIInterval**)obind->valuep + idx), OCI_DTYPE_INTERVAL_DS, 0, 0);
|
422
|
+
if (rv != OCI_SUCCESS)
|
423
|
+
oci8_env_raise(oci8_envhp, rv);
|
424
|
+
} while (++idx < obind->maxar_sz);
|
425
|
+
}
|
426
|
+
|
427
|
+
static const oci8_bind_class_t bind_ociinterval_ym_class = {
|
428
|
+
{
|
429
|
+
NULL,
|
430
|
+
oci8_bind_dsc_free,
|
431
|
+
sizeof(oci8_bind_dsc_t)
|
432
|
+
},
|
433
|
+
bind_ociinterval_ym_get,
|
434
|
+
bind_ociinterval_ym_set,
|
435
|
+
bind_ociinterval_ym_init,
|
436
|
+
bind_ociinterval_ym_init_elem,
|
437
|
+
NULL,
|
438
|
+
NULL,
|
439
|
+
NULL,
|
440
|
+
SQLT_INTERVAL_YM
|
441
|
+
};
|
442
|
+
|
443
|
+
static const oci8_bind_class_t bind_ociinterval_ds_class = {
|
444
|
+
{
|
445
|
+
NULL,
|
446
|
+
oci8_bind_dsc_free,
|
447
|
+
sizeof(oci8_bind_dsc_t)
|
448
|
+
},
|
449
|
+
bind_ociinterval_ds_get,
|
450
|
+
bind_ociinterval_ds_set,
|
451
|
+
bind_ociinterval_ds_init,
|
452
|
+
bind_ociinterval_ds_init_elem,
|
453
|
+
NULL,
|
454
|
+
NULL,
|
455
|
+
NULL,
|
456
|
+
SQLT_INTERVAL_DS
|
457
|
+
};
|
458
|
+
|
459
|
+
#endif /* defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0 */
|
460
|
+
|
461
|
+
void Init_oci_datetime(void)
|
462
|
+
{
|
463
|
+
oci8_define_bind_class("OCIDate", &bind_ocidate_class);
|
464
|
+
|
465
|
+
#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0
|
466
|
+
if (oracle_client_version >= ORAVER_9_0) {
|
467
|
+
oci8_define_bind_class("OCITimestamp", &bind_ocitimestamp_class);
|
468
|
+
oci8_define_bind_class("OCIIntervalYM", &bind_ociinterval_ym_class);
|
469
|
+
oci8_define_bind_class("OCIIntervalDS", &bind_ociinterval_ds_class);
|
470
|
+
}
|
471
|
+
#endif
|
472
|
+
|
473
|
+
}
|