ruby-oci8 2.1.5.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +17 -0
- data/COPYING +30 -0
- data/COPYING_old +64 -0
- data/ChangeLog +2779 -0
- data/Makefile +92 -0
- data/NEWS +660 -0
- data/README.md +43 -0
- data/VERSION +1 -0
- data/dist-files +91 -0
- data/docs/install-binary-package.md +40 -0
- data/docs/install-full-client.md +116 -0
- data/docs/install-instant-client.md +167 -0
- data/docs/platform-specific-issues.md +197 -0
- data/docs/report-installation-issue.md +50 -0
- data/lib/.document +1 -0
- data/lib/dbd/OCI8.rb +591 -0
- data/lib/oci8.rb +147 -0
- data/lib/oci8.rb.in +147 -0
- data/lib/oci8/.document +8 -0
- data/lib/oci8/bindtype.rb +350 -0
- data/lib/oci8/compat.rb +113 -0
- data/lib/oci8/connection_pool.rb +108 -0
- data/lib/oci8/cursor.rb +564 -0
- data/lib/oci8/datetime.rb +605 -0
- data/lib/oci8/encoding-init.rb +79 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2092 -0
- data/lib/oci8/object.rb +605 -0
- data/lib/oci8/oci8.rb +560 -0
- data/lib/oci8/ocihandle.rb +607 -0
- data/lib/oci8/oracle_version.rb +143 -0
- data/lib/oci8/properties.rb +134 -0
- data/lib/oci8lib_200.so +0 -0
- data/metaconfig +142 -0
- data/pre-distclean.rb +7 -0
- data/ruby-oci8.gemspec +80 -0
- data/setup.rb +1333 -0
- data/test/README +42 -0
- data/test/config.rb +184 -0
- data/test/setup_test_object.sql +171 -0
- data/test/test_all.rb +54 -0
- data/test/test_appinfo.rb +63 -0
- data/test/test_array_dml.rb +333 -0
- data/test/test_bind_raw.rb +46 -0
- data/test/test_bind_string.rb +106 -0
- data/test/test_bind_time.rb +178 -0
- data/test/test_break.rb +124 -0
- data/test/test_clob.rb +98 -0
- data/test/test_connection_pool.rb +125 -0
- data/test/test_connstr.rb +81 -0
- data/test/test_datetime.rb +581 -0
- data/test/test_dbi.rb +366 -0
- data/test/test_dbi_clob.rb +53 -0
- data/test/test_encoding.rb +104 -0
- data/test/test_error.rb +88 -0
- data/test/test_metadata.rb +1485 -0
- data/test/test_object.rb +462 -0
- data/test/test_oci8.rb +489 -0
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +256 -0
- data/test/test_oranumber.rb +787 -0
- data/test/test_rowid.rb +33 -0
- metadata +109 -0
data/test/test_oci8.rb
ADDED
@@ -0,0 +1,489 @@
|
|
1
|
+
require 'oci8'
|
2
|
+
require 'test/unit'
|
3
|
+
require File.dirname(__FILE__) + '/config'
|
4
|
+
require 'bigdecimal'
|
5
|
+
require 'rational'
|
6
|
+
|
7
|
+
class TestOCI8 < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@conn = get_oci8_connection
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
@conn.logoff
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_rename
|
18
|
+
drop_table('test_table')
|
19
|
+
drop_table('test_rename_table')
|
20
|
+
sql = <<-EOS
|
21
|
+
CREATE TABLE test_rename_table
|
22
|
+
(C CHAR(10) NOT NULL)
|
23
|
+
EOS
|
24
|
+
@conn.exec(sql)
|
25
|
+
@conn.exec("RENAME test_rename_table TO test_table")
|
26
|
+
drop_table('test_rename_table')
|
27
|
+
end
|
28
|
+
|
29
|
+
# USE_DYNAMIC_FETCH doesn't work well...
|
30
|
+
# This test is disabled.
|
31
|
+
def _test_long_type
|
32
|
+
drop_table('test_table')
|
33
|
+
@conn.exec('CREATE TABLE test_table (id number(38), lng long)')
|
34
|
+
test_data1 = 'a' * 70000
|
35
|
+
test_data2 = 'b' * 3000
|
36
|
+
test_data3 = nil
|
37
|
+
test_data4 = 'c' * 70000
|
38
|
+
@conn.exec('insert into test_table values (:1, :2)', 1, test_data1)
|
39
|
+
@conn.exec('insert into test_table values (:1, :2)', 2, [test_data2, :long])
|
40
|
+
@conn.exec('insert into test_table values (:1, :2)', 3, [nil, :long])
|
41
|
+
@conn.exec('insert into test_table values (:1, :2)', 4, [test_data4, :long])
|
42
|
+
|
43
|
+
[8000, 65535, 65536, 80000].each do |read_len|
|
44
|
+
@conn.long_read_len = read_len
|
45
|
+
cursor = @conn.parse('SELECT lng from test_table order by id')
|
46
|
+
cursor.exec
|
47
|
+
assert_equal(test_data1, cursor.fetch[0])
|
48
|
+
assert_equal(test_data2, cursor.fetch[0])
|
49
|
+
assert_equal(test_data3, cursor.fetch[0])
|
50
|
+
assert_equal(test_data4, cursor.fetch[0])
|
51
|
+
cursor.close
|
52
|
+
end
|
53
|
+
drop_table('test_table')
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_long_type
|
57
|
+
@conn.long_read_len = 80000
|
58
|
+
drop_table('test_table')
|
59
|
+
@conn.exec('CREATE TABLE test_table (id number(38), lng long)')
|
60
|
+
test_data1 = 'a' * 70000
|
61
|
+
test_data2 = 'b' * 3000
|
62
|
+
test_data3 = nil
|
63
|
+
test_data4 = 'c' * 70000
|
64
|
+
@conn.exec('insert into test_table values (:1, :2)', 1, test_data1)
|
65
|
+
@conn.exec('insert into test_table values (:1, :2)', 2, [test_data2, :long])
|
66
|
+
@conn.exec('insert into test_table values (:1, :2)', 3, [nil, :long])
|
67
|
+
@conn.exec('insert into test_table values (:1, :2)', 4, [test_data4, :long])
|
68
|
+
|
69
|
+
cursor = @conn.parse('SELECT lng from test_table order by id')
|
70
|
+
cursor.exec
|
71
|
+
assert_equal(test_data1, cursor.fetch[0])
|
72
|
+
assert_equal(test_data2, cursor.fetch[0])
|
73
|
+
assert_equal(test_data3, cursor.fetch[0])
|
74
|
+
assert_equal(test_data4, cursor.fetch[0])
|
75
|
+
cursor.close
|
76
|
+
drop_table('test_table')
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_select
|
80
|
+
drop_table('test_table')
|
81
|
+
sql = <<-EOS
|
82
|
+
CREATE TABLE test_table
|
83
|
+
(C CHAR(10) NOT NULL,
|
84
|
+
V VARCHAR2(20),
|
85
|
+
N NUMBER(10, 2),
|
86
|
+
D1 DATE, D2 DATE, D3 DATE, D4 DATE,
|
87
|
+
INT NUMBER(30), BIGNUM NUMBER(30))
|
88
|
+
STORAGE (
|
89
|
+
INITIAL 4k
|
90
|
+
NEXT 4k
|
91
|
+
MINEXTENTS 1
|
92
|
+
MAXEXTENTS UNLIMITED
|
93
|
+
PCTINCREASE 0)
|
94
|
+
EOS
|
95
|
+
@conn.exec(sql)
|
96
|
+
cursor = @conn.parse("INSERT INTO test_table VALUES (:C, :V, :N, :D1, :D2, :D3, :D4, :INT, :BIGNUM)")
|
97
|
+
1.upto(10) do |i|
|
98
|
+
if i == 1
|
99
|
+
dt = [nil, OraDate]
|
100
|
+
else
|
101
|
+
dt = OraDate.new(2000 + i, i % 2 == 0 ? 7 : 1, 3, 23, 59, 59)
|
102
|
+
end
|
103
|
+
cursor.exec(format("%10d", i * 10), i.to_s, i, dt, dt, dt, dt, i * 11111111111, i * 10000000000)
|
104
|
+
end
|
105
|
+
cursor.close
|
106
|
+
cursor = @conn.parse("SELECT * FROM test_table ORDER BY c")
|
107
|
+
cursor.define(5, Time) # define 5th column as Time
|
108
|
+
cursor.define(6, Date) # define 6th column as Date
|
109
|
+
cursor.define(7, DateTime) # define 7th column as DateTime
|
110
|
+
cursor.define(8, Integer) # define 8th column as Integer
|
111
|
+
cursor.define(9, Bignum) # define 9th column as Bignum
|
112
|
+
cursor.exec
|
113
|
+
assert_equal(["C", "V", "N", "D1", "D2", "D3", "D4", "INT", "BIGNUM"], cursor.get_col_names)
|
114
|
+
1.upto(10) do |i|
|
115
|
+
rv = cursor.fetch
|
116
|
+
assert_equal(format("%10d", i * 10), rv[0])
|
117
|
+
assert_equal(i.to_s, rv[1])
|
118
|
+
assert_equal(i, rv[2])
|
119
|
+
if i == 1
|
120
|
+
assert_nil(rv[3])
|
121
|
+
assert_nil(rv[4])
|
122
|
+
assert_nil(rv[5])
|
123
|
+
assert_nil(rv[6])
|
124
|
+
else
|
125
|
+
month = i % 2 == 0 ? 7 : 1
|
126
|
+
tm = Time.local(2000 + i, month, 3, 23, 59, 59)
|
127
|
+
dt = Date.civil(2000 + i, month, 3)
|
128
|
+
dttm = DateTime.civil(2000 + i, month, 3, 23, 59, 59, tm.utc_offset.to_r/86400)
|
129
|
+
assert_equal(tm, rv[3])
|
130
|
+
assert_equal(tm, rv[4])
|
131
|
+
assert_equal(dt, rv[5])
|
132
|
+
assert_equal(dttm, rv[6])
|
133
|
+
end
|
134
|
+
assert_equal(i * 11111111111, rv[7])
|
135
|
+
assert_equal(i * 10000000000, rv[8])
|
136
|
+
end
|
137
|
+
assert_nil(cursor.fetch)
|
138
|
+
|
139
|
+
# fetch_hash with block
|
140
|
+
cursor.exec
|
141
|
+
i = 1
|
142
|
+
cursor.fetch_hash do |row|
|
143
|
+
assert_equal(format("%10d", i * 10), row['C'])
|
144
|
+
assert_equal(i.to_s, row['V'])
|
145
|
+
assert_equal(i, row['N'])
|
146
|
+
if i == 1
|
147
|
+
assert_nil(row['D1'])
|
148
|
+
assert_nil(row['D2'])
|
149
|
+
assert_nil(row['D3'])
|
150
|
+
assert_nil(row['D4'])
|
151
|
+
else
|
152
|
+
month = i % 2 == 0 ? 7 : 1
|
153
|
+
tm = Time.local(2000 + i, month, 3, 23, 59, 59)
|
154
|
+
dt = Date.civil(2000 + i, month, 3)
|
155
|
+
dttm = DateTime.civil(2000 + i, month, 3, 23, 59, 59, tm.utc_offset.to_r/86400)
|
156
|
+
assert_equal(tm, row['D1'])
|
157
|
+
assert_equal(tm, row['D2'])
|
158
|
+
assert_equal(dt, row['D3'])
|
159
|
+
assert_equal(dttm, row['D4'])
|
160
|
+
end
|
161
|
+
assert_equal(i * 11111111111, row['INT'])
|
162
|
+
assert_equal(i * 10000000000, row['BIGNUM'])
|
163
|
+
i += 1
|
164
|
+
end
|
165
|
+
assert_equal(11, i)
|
166
|
+
|
167
|
+
cursor.close
|
168
|
+
drop_table('test_table')
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_bind_cursor
|
172
|
+
# FIXME: check again after upgrading Oracle 9.2 to 9.2.0.4.
|
173
|
+
return if $oracle_version < OCI8::ORAVER_10_1
|
174
|
+
|
175
|
+
drop_table('test_table')
|
176
|
+
sql = <<-EOS
|
177
|
+
CREATE TABLE test_table
|
178
|
+
(C CHAR(10) NOT NULL,
|
179
|
+
V VARCHAR2(20),
|
180
|
+
N NUMBER(10, 2),
|
181
|
+
D1 DATE, D2 DATE, D3 DATE,
|
182
|
+
INT NUMBER(30), BIGNUM NUMBER(30))
|
183
|
+
STORAGE (
|
184
|
+
INITIAL 4k
|
185
|
+
NEXT 4k
|
186
|
+
MINEXTENTS 1
|
187
|
+
MAXEXTENTS UNLIMITED
|
188
|
+
PCTINCREASE 0)
|
189
|
+
EOS
|
190
|
+
@conn.exec(sql)
|
191
|
+
cursor = @conn.parse("INSERT INTO test_table VALUES (:C, :V, :N, :D1, :D2, :D3, :INT, :BIGNUM)")
|
192
|
+
1.upto(10) do |i|
|
193
|
+
if i == 1
|
194
|
+
dt = [nil, OraDate]
|
195
|
+
else
|
196
|
+
dt = OraDate.new(2000 + i, 8, 3, 23, 59, 59)
|
197
|
+
end
|
198
|
+
cursor.exec(format("%10d", i * 10), i.to_s, i, dt, dt, dt, i, i)
|
199
|
+
end
|
200
|
+
cursor.close
|
201
|
+
plsql = @conn.parse("BEGIN OPEN :cursor FOR SELECT * FROM test_table ORDER BY c; END;")
|
202
|
+
plsql.bind_param(':cursor', nil, OCI8::Cursor)
|
203
|
+
plsql.exec
|
204
|
+
cursor = plsql[':cursor']
|
205
|
+
cursor.define(5, DateTime) # define 5th column as DateTime
|
206
|
+
cursor.define(6, Date) # define 6th column as Date
|
207
|
+
cursor.define(7, Integer) # define 7th column as Integer
|
208
|
+
cursor.define(8, Bignum) # define 8th column as Integer
|
209
|
+
assert_equal(["C", "V", "N", "D1", "D2", "D3", "INT", "BIGNUM"], cursor.get_col_names)
|
210
|
+
1.upto(10) do |i|
|
211
|
+
rv = cursor.fetch
|
212
|
+
assert_equal(format("%10d", i * 10), rv[0])
|
213
|
+
assert_equal(i.to_s, rv[1])
|
214
|
+
assert_equal(i, rv[2])
|
215
|
+
if i == 1
|
216
|
+
assert_nil(rv[3])
|
217
|
+
assert_nil(rv[4])
|
218
|
+
assert_nil(rv[5])
|
219
|
+
else
|
220
|
+
dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
|
221
|
+
tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
|
222
|
+
dt = Date.civil(2000 + i, 8, 3)
|
223
|
+
assert_equal(tm, rv[3])
|
224
|
+
assert_equal(dttm, rv[4])
|
225
|
+
assert_equal(dt, rv[5])
|
226
|
+
end
|
227
|
+
assert_equal(i, rv[6])
|
228
|
+
assert_equal(i, rv[7])
|
229
|
+
end
|
230
|
+
assert_nil(cursor.fetch)
|
231
|
+
cursor.close
|
232
|
+
drop_table('test_table')
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_cursor_in_result_set
|
236
|
+
drop_table('test_table')
|
237
|
+
sql = <<-EOS
|
238
|
+
CREATE TABLE test_table (N NUMBER(10, 2))
|
239
|
+
STORAGE (
|
240
|
+
INITIAL 4k
|
241
|
+
NEXT 4k
|
242
|
+
MINEXTENTS 1
|
243
|
+
MAXEXTENTS UNLIMITED
|
244
|
+
PCTINCREASE 0)
|
245
|
+
EOS
|
246
|
+
@conn.exec(sql)
|
247
|
+
cursor = @conn.parse("INSERT INTO test_table VALUES (:1)")
|
248
|
+
1.upto(10) do |i|
|
249
|
+
cursor.exec(i)
|
250
|
+
end
|
251
|
+
cursor.close
|
252
|
+
cursor = @conn.exec(<<EOS)
|
253
|
+
select a.n, cursor (select a.n + b.n
|
254
|
+
from test_table b
|
255
|
+
order by n)
|
256
|
+
from test_table a
|
257
|
+
order by n
|
258
|
+
EOS
|
259
|
+
1.upto(10) do |i|
|
260
|
+
row = cursor.fetch
|
261
|
+
assert_equal(i, row[0])
|
262
|
+
cursor_in_result_set = row[1]
|
263
|
+
1.upto(10) do |j|
|
264
|
+
row2 = cursor_in_result_set.fetch
|
265
|
+
assert_equal(i + j, row2[0])
|
266
|
+
end
|
267
|
+
assert_nil(cursor_in_result_set.fetch) # check end of row data
|
268
|
+
cursor_in_result_set.close
|
269
|
+
end
|
270
|
+
assert_nil(cursor.fetch) # check end of row data
|
271
|
+
drop_table('test_table')
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_binary_float
|
275
|
+
return if $oracle_version < OCI8::ORAVER_10_1
|
276
|
+
|
277
|
+
# Oracle 10g or upper
|
278
|
+
cursor = @conn.parse("select CAST(:1 AS BINARY_FLOAT), CAST(:2 AS BINARY_DOUBLE) from dual")
|
279
|
+
bind_val = -1.0
|
280
|
+
cursor.bind_param(1, 10.0, :binary_double)
|
281
|
+
cursor.bind_param(2, nil, :binary_double)
|
282
|
+
while bind_val < 10.0
|
283
|
+
cursor[2] = bind_val
|
284
|
+
cursor.exec
|
285
|
+
rv = cursor.fetch
|
286
|
+
assert_equal(10.0, rv[0])
|
287
|
+
assert_equal(bind_val, rv[1])
|
288
|
+
bind_val += 1.234
|
289
|
+
end
|
290
|
+
[-1.0/0.0, # -Infinite
|
291
|
+
+1.0/0.0, # +Infinite
|
292
|
+
0.0/0.0 # NaN
|
293
|
+
].each do |num|
|
294
|
+
cursor[1] = num
|
295
|
+
cursor[2] = num
|
296
|
+
cursor.exec
|
297
|
+
rv = cursor.fetch
|
298
|
+
if num.nan?
|
299
|
+
assert(rv[0].nan?)
|
300
|
+
assert(rv[1].nan?)
|
301
|
+
else
|
302
|
+
assert_equal(num, rv[0])
|
303
|
+
assert_equal(num, rv[1])
|
304
|
+
end
|
305
|
+
end
|
306
|
+
cursor.close
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_clob_nclob_and_blob
|
310
|
+
return if OCI8::oracle_client_version < OCI8::ORAVER_8_1
|
311
|
+
|
312
|
+
drop_table('test_table')
|
313
|
+
sql = <<-EOS
|
314
|
+
CREATE TABLE test_table (id number(5), C CLOB, NC NCLOB, B BLOB)
|
315
|
+
STORAGE (
|
316
|
+
INITIAL 100k
|
317
|
+
NEXT 100k
|
318
|
+
MINEXTENTS 1
|
319
|
+
MAXEXTENTS UNLIMITED
|
320
|
+
PCTINCREASE 0)
|
321
|
+
EOS
|
322
|
+
@conn.exec(sql)
|
323
|
+
cursor = @conn.parse("INSERT INTO test_table VALUES (:1, :2, :3, :4)")
|
324
|
+
0.upto(9) do |i|
|
325
|
+
val = case i
|
326
|
+
when 5; '' # empty string
|
327
|
+
else format('%d', i) * 4096
|
328
|
+
end
|
329
|
+
cursor.exec(i, OCI8::CLOB.new(@conn, val), OCI8::NCLOB.new(@conn, val), OCI8::BLOB.new(@conn, val))
|
330
|
+
end
|
331
|
+
cursor.close
|
332
|
+
cursor = @conn.exec("select * from test_table order by id")
|
333
|
+
0.upto(9) do |i|
|
334
|
+
rv = cursor.fetch
|
335
|
+
val = case i
|
336
|
+
when 5; '' # empty string
|
337
|
+
else format('%d', i) * 4096
|
338
|
+
end
|
339
|
+
assert_equal(i, rv[0])
|
340
|
+
assert_instance_of(OCI8::CLOB, rv[1])
|
341
|
+
assert_instance_of(OCI8::NCLOB, rv[2])
|
342
|
+
assert_instance_of(OCI8::BLOB, rv[3])
|
343
|
+
assert_equal(val, rv[1].read)
|
344
|
+
assert_equal(val.length, rv[2].size)
|
345
|
+
assert_equal(val, rv[2].read)
|
346
|
+
assert_equal(val, rv[3].read)
|
347
|
+
end
|
348
|
+
assert_nil(cursor.fetch)
|
349
|
+
cursor.close
|
350
|
+
drop_table('test_table')
|
351
|
+
end
|
352
|
+
|
353
|
+
def test_select_number
|
354
|
+
drop_table('test_table')
|
355
|
+
@conn.exec(<<EOS)
|
356
|
+
CREATE TABLE test_table (n NUMBER, n20 NUMBER(20), n14_2 NUMBER(14,2), n15_2 NUMBER(15,2), flt FLOAT)
|
357
|
+
STORAGE (
|
358
|
+
INITIAL 100k
|
359
|
+
NEXT 100k
|
360
|
+
MINEXTENTS 1
|
361
|
+
MAXEXTENTS UNLIMITED
|
362
|
+
PCTINCREASE 0)
|
363
|
+
EOS
|
364
|
+
@conn.exec(<<EOS)
|
365
|
+
INSERT INTO test_table values(12345678901234, 12345678901234567890, 123456789012.34, 1234567890123.45, 1234.5)
|
366
|
+
EOS
|
367
|
+
@conn.exec("select * from test_table") do |row|
|
368
|
+
assert_equal(row[0], 12345678901234)
|
369
|
+
assert_equal(row[1], 12345678901234567890)
|
370
|
+
assert_equal(row[2], 123456789012.34)
|
371
|
+
assert_equal(row[3], BigDecimal("1234567890123.45"))
|
372
|
+
assert_equal(row[4], 1234.5)
|
373
|
+
assert_instance_of(BigDecimal, row[0])
|
374
|
+
assert_instance_of(Bignum, row[1])
|
375
|
+
assert_instance_of(Float, row[2])
|
376
|
+
assert_instance_of(BigDecimal, row[3])
|
377
|
+
assert_instance_of(Float, row[4])
|
378
|
+
end
|
379
|
+
drop_table('test_table')
|
380
|
+
end
|
381
|
+
|
382
|
+
def test_bind_number_with_implicit_conversions
|
383
|
+
src = [1, 1.2, BigDecimal("1.2"), Rational(12, 10)]
|
384
|
+
int = [1, 1, 1, 1]
|
385
|
+
flt = [1, 1.2, 1.2, 1.2]
|
386
|
+
dec = [BigDecimal("1"), BigDecimal("1.2"), BigDecimal("1.2"), BigDecimal("1.2")]
|
387
|
+
rat = [Rational(1), Rational(12, 10), Rational(12, 10), Rational(12, 10)]
|
388
|
+
|
389
|
+
cursor = @conn.parse("begin :1 := :2; end;")
|
390
|
+
|
391
|
+
# Float
|
392
|
+
cursor.bind_param(1, nil, Float)
|
393
|
+
cursor.bind_param(2, nil, Float)
|
394
|
+
src.each_with_index do |s, idx|
|
395
|
+
cursor[2] = s
|
396
|
+
cursor.exec
|
397
|
+
assert_equal(cursor[1], flt[idx])
|
398
|
+
assert_kind_of(Float, cursor[1])
|
399
|
+
end
|
400
|
+
|
401
|
+
# Fixnum
|
402
|
+
cursor.bind_param(1, nil, Fixnum)
|
403
|
+
cursor.bind_param(2, nil, Fixnum)
|
404
|
+
src.each_with_index do |s, idx|
|
405
|
+
cursor[2] = s
|
406
|
+
cursor.exec
|
407
|
+
assert_equal(cursor[1], int[idx])
|
408
|
+
assert_kind_of(Fixnum, cursor[1])
|
409
|
+
end
|
410
|
+
|
411
|
+
# Integer
|
412
|
+
cursor.bind_param(1, nil, Integer)
|
413
|
+
cursor.bind_param(2, nil, Integer)
|
414
|
+
src.each_with_index do |s, idx|
|
415
|
+
cursor[2] = s
|
416
|
+
cursor.exec
|
417
|
+
assert_equal(cursor[1], int[idx])
|
418
|
+
assert_kind_of(Integer, cursor[1])
|
419
|
+
end
|
420
|
+
|
421
|
+
# BigDecimal
|
422
|
+
cursor.bind_param(1, nil, BigDecimal)
|
423
|
+
cursor.bind_param(2, nil, BigDecimal)
|
424
|
+
src.each_with_index do |s, idx|
|
425
|
+
cursor[2] = s
|
426
|
+
cursor.exec
|
427
|
+
assert_equal(cursor[1], dec[idx])
|
428
|
+
assert_kind_of(BigDecimal, cursor[1])
|
429
|
+
end
|
430
|
+
|
431
|
+
# Rational
|
432
|
+
cursor.bind_param(1, nil, Rational)
|
433
|
+
cursor.bind_param(2, nil, Rational)
|
434
|
+
src.each_with_index do |s, idx|
|
435
|
+
cursor[2] = s
|
436
|
+
cursor.exec
|
437
|
+
assert_equal(cursor[1], rat[idx])
|
438
|
+
assert_kind_of(Rational, cursor[1])
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
def test_parse_sets_query_on_cursor
|
443
|
+
statement = "select * from country where country_code = 'ja'"
|
444
|
+
cursor = @conn.parse(statement)
|
445
|
+
assert_equal(statement, cursor.statement)
|
446
|
+
end
|
447
|
+
|
448
|
+
def test_last_error
|
449
|
+
# OCI8#parse and OCI8#exec reset OCI8#last_error
|
450
|
+
@conn.last_error = 'dummy'
|
451
|
+
@conn.exec('begin null; end;')
|
452
|
+
assert_nil(@conn.last_error)
|
453
|
+
@conn.last_error = 'dummy'
|
454
|
+
cursor = @conn.parse('select col1, max(col2) from (select 1 as col1, null as col2 from dual) group by col1')
|
455
|
+
assert_nil(@conn.last_error)
|
456
|
+
|
457
|
+
# When an OCI function returns OCI_SUCCESS_WITH_INFO, OCI8#last_error is set.
|
458
|
+
@conn.last_error = 'dummy'
|
459
|
+
cursor.exec
|
460
|
+
assert_equal('dummy', @conn.last_error)
|
461
|
+
cursor.fetch
|
462
|
+
assert_kind_of(OCISuccessWithInfo, @conn.last_error)
|
463
|
+
assert_equal(24347, @conn.last_error.code)
|
464
|
+
end
|
465
|
+
|
466
|
+
def test_environment_handle
|
467
|
+
# OCI_ATTR_HEAPALLOC
|
468
|
+
assert_operator(OCI8.send(:class_variable_get, :@@environment_handle).send(:attr_get_ub4, 30), :>, 0)
|
469
|
+
# OCI_ATTR_OBJECT
|
470
|
+
assert(OCI8.send(:class_variable_get, :@@environment_handle).send(:attr_get_boolean, 2))
|
471
|
+
# OCI_ATTR_SHARED_HEAPALLOC
|
472
|
+
assert_equal(0, OCI8.send(:class_variable_get, :@@environment_handle).send(:attr_get_ub4, 84))
|
473
|
+
end
|
474
|
+
|
475
|
+
def test_process_handle
|
476
|
+
# OCI_ATTR_MEMPOOL_APPNAME
|
477
|
+
assert_equal('', OCI8.send(:class_variable_get, :@@process_handle).send(:attr_get_string, 90))
|
478
|
+
# OCI_ATTR_MEMPOOL_SIZE
|
479
|
+
assert_equal(0, OCI8.send(:class_variable_get, :@@process_handle).send(:attr_get_ub4, 88))
|
480
|
+
end
|
481
|
+
|
482
|
+
def test_client_driver_name
|
483
|
+
if OCI8.oracle_client_version >= OCI8::ORAVER_11_1 and @conn.oracle_server_version >= OCI8::ORAVER_11_1
|
484
|
+
sid = @conn.select_one("select userenv('sid') from dual")[0].to_i
|
485
|
+
driver_name = @conn.select_one('select client_driver from v$session_connect_info where sid = :1', sid)[0]
|
486
|
+
assert_equal('rubyoci8', driver_name)
|
487
|
+
end
|
488
|
+
end
|
489
|
+
end # TestOCI8
|