ruby-oci8 1.0.7-x86-mswin32-60 → 2.0.1-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/ChangeLog +1289 -383
  2. data/Makefile +48 -12
  3. data/NEWS +5 -419
  4. data/README +56 -385
  5. data/VERSION +1 -1
  6. data/dist-files +27 -27
  7. data/lib/.document +2 -0
  8. data/lib/dbd/OCI8.rb +2 -17
  9. data/lib/oci8.rb +48 -1622
  10. data/lib/oci8.rb.in +48 -1622
  11. data/lib/oci8/.document +5 -0
  12. data/lib/oci8/compat.rb +108 -0
  13. data/lib/oci8/datetime.rb +491 -0
  14. data/lib/oci8/encoding-init.rb +40 -0
  15. data/lib/oci8/encoding.yml +537 -0
  16. data/lib/oci8/metadata.rb +2077 -0
  17. data/lib/oci8/object.rb +548 -0
  18. data/lib/oci8/oci8.rb +798 -0
  19. data/lib/oci8/oracle_version.rb +144 -0
  20. data/lib/oci8lib_18.so +0 -0
  21. data/lib/oci8lib_191.so +0 -0
  22. data/metaconfig +3 -3
  23. data/ruby-oci8.gemspec +24 -15
  24. data/setup.rb +4 -4
  25. data/test/config.rb +64 -84
  26. data/test/test_all.rb +14 -21
  27. data/test/test_array_dml.rb +333 -0
  28. data/test/test_bind_raw.rb +18 -25
  29. data/test/test_bind_time.rb +78 -91
  30. data/test/test_break.rb +37 -35
  31. data/test/test_clob.rb +33 -89
  32. data/test/test_connstr.rb +5 -4
  33. data/test/test_datetime.rb +469 -0
  34. data/test/test_dbi.rb +99 -60
  35. data/test/test_dbi_clob.rb +3 -8
  36. data/test/test_metadata.rb +65 -51
  37. data/test/test_oci8.rb +151 -55
  38. data/test/test_oracle_version.rb +70 -0
  39. data/test/test_oradate.rb +76 -83
  40. data/test/test_oranumber.rb +405 -71
  41. data/test/test_rowid.rb +6 -11
  42. metadata +21 -25
  43. data/ext/oci8/oci8lib.so +0 -0
  44. data/ruby-oci8.spec +0 -62
  45. data/support/README +0 -4
  46. data/support/runit/assert.rb +0 -281
  47. data/support/runit/cui/testrunner.rb +0 -101
  48. data/support/runit/error.rb +0 -4
  49. data/support/runit/method_mappable.rb +0 -20
  50. data/support/runit/robserver.rb +0 -25
  51. data/support/runit/setuppable.rb +0 -15
  52. data/support/runit/teardownable.rb +0 -16
  53. data/support/runit/testcase.rb +0 -113
  54. data/support/runit/testfailure.rb +0 -25
  55. data/support/runit/testresult.rb +0 -121
  56. data/support/runit/testsuite.rb +0 -43
  57. data/support/runit/version.rb +0 -3
  58. data/test/test_describe.rb +0 -137
@@ -0,0 +1,333 @@
1
+ require 'oci8'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/config'
4
+
5
+ class TestArrayDML < Test::Unit::TestCase
6
+ def setup
7
+ @conn = get_oci8_connection
8
+ end
9
+
10
+ def teardown
11
+ @conn.logoff
12
+ end
13
+
14
+ # test inserting arrays with different data types
15
+ # including char, varchar2, number, date and so on
16
+ def test_array_insert1
17
+ drop_table('test_table')
18
+ sql = <<-EOS
19
+ CREATE TABLE test_table
20
+ (C CHAR(10) NOT NULL,
21
+ V VARCHAR2(20),
22
+ N NUMBER(10, 2),
23
+ D DATE,
24
+ INT NUMBER(30),
25
+ BIGNUM NUMBER(30),
26
+ T TIMESTAMP)
27
+ STORAGE (
28
+ INITIAL 4k
29
+ NEXT 4k
30
+ MINEXTENTS 1
31
+ MAXEXTENTS UNLIMITED
32
+ PCTINCREASE 0)
33
+ EOS
34
+ @conn.exec(sql)
35
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:C, :V, :N, :D, :INT, :BIGNUM, :T)")
36
+ max_array_size = 3
37
+ cursor.max_array_size= max_array_size
38
+
39
+ cursor.bind_param_array(1, nil, String)
40
+ cursor.bind_param_array(2, nil ,String)
41
+ cursor.bind_param_array(3, nil, Fixnum)
42
+ cursor.bind_param_array(4, nil, OraDate)
43
+ cursor.bind_param_array(5, nil, Integer)
44
+ cursor.bind_param_array(6, nil, Bignum)
45
+ cursor.bind_param_array(7, nil, DateTime)
46
+
47
+ c_arr = Array.new
48
+ v_arr = Array.new
49
+ n_arr = Array.new
50
+ d_arr = Array.new
51
+ int_arr = Array.new
52
+ bignum_arr = Array.new
53
+ t_arr = Array.new
54
+
55
+ 1.upto(30) do |i|
56
+ c_arr << format("%10d", i * 10)
57
+ v_arr << i.to_s
58
+ n_arr << i
59
+ d_arr << OraDate.new(2000 + i, 12, 24, 23, 59, 59)
60
+ int_arr << i * 11111111111
61
+ bignum_arr << i * 10000000000
62
+ t_arr << DateTime.new(2000 + i, 12, 24, 23, 59, 59)
63
+
64
+ if i%max_array_size == 0
65
+ cursor[1] = c_arr
66
+ cursor[2] = v_arr
67
+ cursor[3] = n_arr
68
+ cursor[4] = d_arr
69
+ cursor[5] = int_arr
70
+ cursor[6] = bignum_arr
71
+ cursor[7] = t_arr
72
+
73
+ r = cursor.exec_array
74
+ assert_equal(max_array_size, r)
75
+ assert_equal(c_arr, cursor[1])
76
+ assert_equal(v_arr, cursor[2])
77
+ assert_equal(n_arr, cursor[3])
78
+ assert_equal(d_arr, cursor[4])
79
+ assert_equal(int_arr, cursor[5])
80
+ assert_equal(bignum_arr, cursor[6])
81
+ assert_equal(t_arr, cursor[7])
82
+ c_arr.clear
83
+ v_arr.clear
84
+ n_arr.clear
85
+ d_arr.clear
86
+ int_arr.clear
87
+ bignum_arr.clear
88
+ t_arr.clear
89
+ end
90
+ end
91
+ cursor.close
92
+
93
+ cursor = @conn.parse("SELECT * FROM test_table ORDER BY c")
94
+ cursor.define(5, Integer)
95
+ cursor.define(6, Bignum)
96
+ cursor.exec
97
+ assert_equal(["C","V","N","D","INT","BIGNUM","T"], cursor.get_col_names)
98
+ 1.upto(30) do |i|
99
+ rv = cursor.fetch
100
+ assert_equal(format("%10d", i * 10), rv[0])
101
+ assert_equal(i.to_s, rv[1])
102
+ assert_equal(i, rv[2])
103
+ tm = Time.local(2000 + i, 12, 24, 23, 59, 59)
104
+ assert_equal(tm, rv[3])
105
+ assert_equal(i * 11111111111, rv[4])
106
+ assert_equal(i * 10000000000, rv[5])
107
+ assert_equal(tm, rv[6])
108
+ end
109
+ assert_nil(cursor.fetch)
110
+ drop_table('test_table')
111
+ end
112
+
113
+ # Raise error when binding arrays are not the same size
114
+ def test_array_insert2
115
+ drop_table('test_table')
116
+ sql = <<-EOS
117
+ CREATE TABLE test_table
118
+ (N NUMBER(10, 2) NOT NULL,
119
+ V VARCHAR(20))
120
+ EOS
121
+ @conn.exec(sql)
122
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
123
+ max_array_size = 10
124
+ cursor.max_array_size = max_array_size
125
+ cursor.bind_param_array(1, nil, Fixnum)
126
+ cursor.bind_param_array(2, nil, String)
127
+ n_arr = Array.new
128
+ v_arr = Array.new
129
+ 1.upto(max_array_size) do |i|
130
+ n_arr << i
131
+ v_arr << i.to_s if i != max_array_size
132
+ end
133
+ cursor[1] = n_arr
134
+ assert_raise(RuntimeError) { cursor[2] = v_arr }
135
+ cursor.close
136
+
137
+ drop_table('test_table')
138
+ end
139
+
140
+ # All binds are clear from cursor after calling "max_array_size=",
141
+ # in that case, you have to re-bind the array parameters
142
+ # otherwise, an error will be raised.
143
+ def test_array_insert3
144
+ drop_table('test_table')
145
+ sql = <<-EOS
146
+ CREATE TABLE test_table
147
+ (N NUMBER(10, 2) NOT NULL,
148
+ V VARCHAR(20),
149
+ T TIMESTAMP)
150
+ EOS
151
+ @conn.exec(sql)
152
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V, :T)")
153
+ cursor.max_array_size = 3
154
+ cursor.bind_param_array(1, [1, 2, 3])
155
+ cursor.bind_param_array(2, ['happy', 'new', 'year'])
156
+ cursor.bind_param_array(3, [Time.gm(1990,1,1), Time.gm(2000,1,1), Time.gm(2010,1,1)])
157
+ assert_nothing_raised() { cursor.exec_array }
158
+ cursor.max_array_size = 2
159
+ assert_raise(RuntimeError) { cursor.exec_array }
160
+ drop_table('test_table')
161
+ end
162
+
163
+ # The size of binding arrays are not required to be same as max_array_size. The
164
+ # only requirement is that they should be the same size, and the size will be
165
+ # used as execution count for OCIStmtExecute.
166
+ def test_array_insert4
167
+ drop_table('test_table')
168
+ sql = <<-EOS
169
+ CREATE TABLE test_table
170
+ (N NUMBER(10, 2) NOT NULL,
171
+ V VARCHAR(20))
172
+ EOS
173
+ @conn.exec(sql)
174
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
175
+ max_array_size = 4
176
+ cursor.max_array_size = max_array_size
177
+ cursor.bind_param_array(1, nil, Fixnum)
178
+ cursor.bind_param_array(2, nil, String)
179
+ n_arr = Array.new
180
+ v_arr = Array.new
181
+ 1.upto( max_array_size - 1 ) do |i|
182
+ n_arr << i
183
+ v_arr << i.to_s
184
+ end
185
+ cursor[1] = n_arr
186
+ cursor[2] = v_arr
187
+ assert_nothing_raised() { cursor.exec_array }
188
+ cursor.close
189
+
190
+ cursor = @conn.parse("SELECT * FROM test_table ORDER BY N")
191
+ cursor.exec
192
+ 1.upto( max_array_size - 1 ) do |i|
193
+ rv = cursor.fetch
194
+ assert_equal(i, rv[0])
195
+ assert_equal(i.to_s, rv[1])
196
+ end
197
+ assert_nil(cursor.fetch)
198
+ cursor.close
199
+ drop_table('test_table')
200
+ end
201
+
202
+ # Inserting "nil" elements with array dml raises an error
203
+ def test_array_insert5
204
+ drop_table('test_table')
205
+ sql = <<-EOS
206
+ CREATE TABLE test_table
207
+ (N NUMBER(10, 2),
208
+ V VARCHAR(20))
209
+ EOS
210
+ @conn.exec(sql)
211
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
212
+ max_array_size = 3
213
+ cursor.max_array_size = max_array_size
214
+ cursor.bind_param_array(1, nil, Fixnum)
215
+ cursor.bind_param_array(2, nil, String)
216
+ assert_raise(RuntimeError) { cursor.exec_array }
217
+ cursor.close
218
+ drop_table('test_table')
219
+ end
220
+
221
+ # delete with array bindings
222
+ def test_array_delete
223
+ drop_table('test_table')
224
+ sql = <<-EOS
225
+ CREATE TABLE test_table
226
+ (N NUMBER(10, 2),
227
+ V VARCHAR(20))
228
+ EOS
229
+ @conn.exec(sql)
230
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
231
+ max_array_size = 10
232
+ cursor.max_array_size = max_array_size
233
+ n_arr = Array.new
234
+ v_arr = Array.new
235
+ 1.upto( max_array_size) do |i|
236
+ n_arr << i
237
+ v_arr << i.to_s
238
+ end
239
+ cursor.bind_param_array(1, nil, Fixnum)
240
+ cursor.bind_param_array(2, nil, String)
241
+ cursor[1] = n_arr
242
+ cursor[2] = v_arr
243
+ cursor.exec_array
244
+ cursor.close
245
+
246
+ cursor = @conn.parse("DELETE FROM test_table WHERE N=:1")
247
+ cursor.max_array_size = max_array_size
248
+ delete_arr = Array.new
249
+ 1.upto(max_array_size) do |i|
250
+ if i%2 == 0
251
+ delete_arr << i
252
+ end
253
+ end
254
+ cursor.bind_param_array(1, nil, Fixnum)
255
+ cursor[1] = delete_arr
256
+ cursor.exec_array
257
+ cursor.close
258
+
259
+ cursor = @conn.parse("SELECT * FROM test_table ORDER BY N")
260
+ cursor.exec
261
+ 1.upto( max_array_size ) do |i|
262
+ if i%2 != 0
263
+ rv = cursor.fetch
264
+ assert_equal(rv[0], i)
265
+ assert_equal(rv[1], i.to_s)
266
+ end
267
+ end
268
+ assert_nil(cursor.fetch)
269
+ cursor.close
270
+
271
+ drop_table('test_table')
272
+ end
273
+
274
+ # update with array bindings
275
+ def test_array_update
276
+ drop_table('test_table')
277
+ sql = <<-EOS
278
+ CREATE TABLE test_table
279
+ (N NUMBER(10, 2),
280
+ V VARCHAR(20))
281
+ EOS
282
+ @conn.exec(sql)
283
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
284
+ max_array_size = 10
285
+ cursor.max_array_size = max_array_size
286
+ n_arr = Array.new
287
+ v_arr = Array.new
288
+ 1.upto( max_array_size) do |i|
289
+ n_arr << i
290
+ v_arr << i.to_s
291
+ end
292
+ cursor.bind_param_array(1, nil, Fixnum)
293
+ cursor.bind_param_array(2, nil, String)
294
+ cursor[1] = n_arr
295
+ cursor[2] = v_arr
296
+ cursor.exec_array
297
+ cursor.close
298
+
299
+ cursor = @conn.parse("UPDATE test_table SET V=:1 WHERE N=:2")
300
+ cursor.max_array_size = max_array_size
301
+ update_arr = Array.new
302
+ update_v_arr = Array.new
303
+ 1.upto(max_array_size) do |i|
304
+ if i%2 == 0
305
+ update_arr << i
306
+ update_v_arr << (i * 10).to_s
307
+ end
308
+ end
309
+ cursor.bind_param_array(1, nil, String)
310
+ cursor.bind_param_array(2, nil, Fixnum)
311
+ cursor[1] = update_v_arr
312
+ cursor[2] = update_arr
313
+ cursor.exec_array
314
+ cursor.close
315
+
316
+ cursor = @conn.parse("SELECT * FROM test_table ORDER BY N")
317
+ cursor.exec
318
+ 1.upto( max_array_size ) do |i|
319
+ rv = cursor.fetch
320
+ if i%2 != 0
321
+ assert_equal(rv[0], i)
322
+ assert_equal(rv[1], i.to_s)
323
+ else
324
+ assert_equal(rv[0], i)
325
+ assert_equal(rv[1], (i * 10).to_s)
326
+ end
327
+ end
328
+ assert_nil(cursor.fetch)
329
+
330
+ cursor.close
331
+ drop_table('test_table')
332
+ end
333
+ end
@@ -1,10 +1,9 @@
1
1
  # Low-level API
2
2
  require 'oci8'
3
- require 'runit/testcase'
4
- require 'runit/cui/testrunner'
3
+ require 'test/unit'
5
4
  require File.dirname(__FILE__) + '/config'
6
5
 
7
- class TestBindRaw < RUNIT::TestCase
6
+ class TestBindRaw < Test::Unit::TestCase
8
7
  CHECK_TARGET = [
9
8
  ["0123456789:;<=>?", "303132333435363738393A3B3C3D3E3F"],
10
9
  ["@ABCDEFGHIJKLMNO", "404142434445464748494A4B4C4D4E4F"],
@@ -14,40 +13,34 @@ class TestBindRaw < RUNIT::TestCase
14
13
  ]
15
14
 
16
15
  def setup
17
- @env, @svc, @stmt = setup_lowapi()
16
+ @conn = get_oci8_connection()
18
17
  end
19
18
 
20
19
  def test_set_raw
21
- @stmt.prepare("BEGIN :hex := RAWTOHEX(:raw); END;")
22
- raw_in = @stmt.bindByName(":raw", OCI_TYPECODE_RAW, 16)
23
- hex_out = @stmt.bindByName(":hex", String, 32)
24
-
20
+ cursor = @conn.parse("BEGIN :hex := RAWTOHEX(:raw); END;")
21
+ cursor.bind_param(:raw, nil, OCI8::RAW, 16)
22
+ cursor.bind_param(:hex, nil, String, 32)
23
+
25
24
  CHECK_TARGET.each do |raw, hex|
26
- raw_in.set(raw)
27
- @stmt.execute(@svc)
28
- assert_equal(hex, hex_out.get())
25
+ cursor[:raw] = raw
26
+ cursor.exec
27
+ assert_equal(hex, cursor[:hex])
29
28
  end
30
29
  end
31
30
 
32
31
  def test_get_raw
33
- @stmt.prepare("BEGIN :raw := HEXTORAW(:hex); END;")
34
- hex_in = @stmt.bindByName(":hex", String, 32)
35
- raw_out = @stmt.bindByName(":raw", OCI_TYPECODE_RAW, 16)
36
-
32
+ cursor = @conn.parse("BEGIN :raw := HEXTORAW(:hex); END;")
33
+ cursor.bind_param(:hex, nil, String, 32)
34
+ cursor.bind_param(:raw, nil, OCI8::RAW, 16)
35
+
37
36
  CHECK_TARGET.each do |raw, hex|
38
- hex_in.set(hex)
39
- @stmt.execute(@svc)
40
- assert_equal(raw, raw_out.get())
37
+ cursor[:hex] = hex
38
+ cursor.exec
39
+ assert_equal(raw, cursor[:raw])
41
40
  end
42
41
  end
43
42
 
44
43
  def teardown
45
- @stmt.free()
46
- @svc.logoff()
47
- @env.free()
44
+ @conn.logoff
48
45
  end
49
46
  end
50
-
51
- if $0 == __FILE__
52
- RUNIT::CUI::TestRunner.run(TestBindRaw.suite())
53
- end
@@ -1,10 +1,8 @@
1
- # Low-level API
2
1
  require 'oci8'
3
- require 'runit/testcase'
4
- require 'runit/cui/testrunner'
2
+ require 'test/unit'
5
3
  require File.dirname(__FILE__) + '/config'
6
4
 
7
- class TestBindTime < RUNIT::TestCase
5
+ class TestBindTime < Test::Unit::TestCase
8
6
 
9
7
  YEAR_CHECK_TARGET = [1971, 1989, 2002, 2037]
10
8
  MON_CHECK_TARGET = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
@@ -14,178 +12,167 @@ class TestBindTime < RUNIT::TestCase
14
12
  SEC_CHECK_TARGET = [0, 15, 30, 45, 59]
15
13
 
16
14
  def setup
17
- @env, @svc, @stmt = setup_lowapi()
15
+ @conn = get_oci8_connection
18
16
  end
19
17
 
20
18
  def test_set_year
21
- @stmt.prepare("BEGIN :year := TO_NUMBER(TO_CHAR(:time, 'SYYYY'), '9999'); END;")
22
- time_in = @stmt.bindByName(":time", Time)
23
- year_out = @stmt.bindByName(":year", Fixnum)
19
+ cursor = @conn.parse("BEGIN :year := TO_NUMBER(TO_CHAR(:time, 'SYYYY'), '9999'); END;")
20
+ cursor.bind_param(:time, Time)
21
+ cursor.bind_param(:year, Fixnum)
22
+
24
23
  YEAR_CHECK_TARGET.each do |i|
25
24
  # set year
26
- time = Time.local(i, 1)
27
- # check result via oracle.
28
- time_in.set(time)
29
- @stmt.execute(@svc)
30
- assert_equal(i, year_out.get())
25
+ cursor[:time] = Time.local(i, 1)
26
+ # check result
27
+ cursor.exec
28
+ assert_equal(i, cursor[:year])
31
29
  end
32
30
  end
33
31
 
34
32
  def test_get_year
35
- @stmt.prepare("BEGIN :time := TO_DATE(TO_CHAR(:year, '0999'), 'SYYYY'); END;")
36
- year_in = @stmt.bindByName(":year", Fixnum)
37
- time_out = @stmt.bindByName(":time", Time)
33
+ cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:year, '0999'), 'SYYYY'); END;")
34
+ cursor.bind_param(:year, Fixnum)
35
+ cursor.bind_param(:time, Time)
38
36
  YEAR_CHECK_TARGET.each do |i|
39
37
  # set time via oracle.
40
- year_in.set(i)
41
- @stmt.execute(@svc)
38
+ cursor[:year] = i
39
+ cursor.exec
42
40
  # check Time#year
43
- assert_equal(i, time_out.get.year)
41
+ assert_equal(i, cursor[:time].year)
44
42
  end
45
43
  end
46
44
 
47
45
  def test_set_mon
48
- @stmt.prepare("BEGIN :mon := TO_NUMBER(TO_CHAR(:time, 'MM'), '99'); END;")
49
- time_in = @stmt.bindByName(":time", Time)
50
- mon_out = @stmt.bindByName(":mon", Fixnum)
46
+ cursor = @conn.parse("BEGIN :mon := TO_NUMBER(TO_CHAR(:time, 'MM'), '99'); END;")
47
+ cursor.bind_param(:time, Time)
48
+ cursor.bind_param(:mon, Fixnum)
51
49
  MON_CHECK_TARGET.each do |i|
52
50
  # set mon
53
- time = Time.local(2001, i)
51
+ cursor[:time] = Time.local(2001, i)
54
52
  # check result via oracle.
55
- time_in.set(time)
56
- @stmt.execute(@svc)
57
- assert_equal(i, mon_out.get())
53
+ cursor.exec
54
+ assert_equal(i, cursor[:mon])
58
55
  end
59
56
  end
60
57
 
61
58
  def test_get_mon
62
- @stmt.prepare("BEGIN :time := TO_DATE(TO_CHAR(:mon, '99'), 'MM'); END;")
63
- mon_in = @stmt.bindByName(":mon", Fixnum)
64
- time_out = @stmt.bindByName(":time", Time)
59
+ cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:mon, '99'), 'MM'); END;")
60
+ cursor.bind_param(:mon, Fixnum)
61
+ cursor.bind_param(:time, Time)
65
62
  MON_CHECK_TARGET.each do |i|
66
63
  # set time via oracle.
67
- mon_in.set(i)
68
- @stmt.execute(@svc)
64
+ cursor[:mon] = i;
65
+ cursor.exec
69
66
  # check Time#mon
70
- assert_equal(i, time_out.get.mon)
67
+ assert_equal(i, cursor[:time].mon)
71
68
  end
72
69
  end
73
70
 
74
71
  def test_set_day
75
- @stmt.prepare("BEGIN :day := TO_NUMBER(TO_CHAR(:time, 'DD'), '99'); END;")
76
- time_in = @stmt.bindByName(":time", Time)
77
- day_out = @stmt.bindByName(":day", Fixnum)
72
+ cursor = @conn.parse("BEGIN :day := TO_NUMBER(TO_CHAR(:time, 'DD'), '99'); END;")
73
+ cursor.bind_param(:time, Time)
74
+ cursor.bind_param(:day, Fixnum)
78
75
  DAY_CHECK_TARGET.each do |i|
79
76
  # set day
80
- time = Time.local(2001, 1, i)
77
+ cursor[:time] = Time.local(2001, 1, i)
81
78
  # check result via oracle.
82
- time_in.set(time)
83
- @stmt.execute(@svc)
84
- assert_equal(i, day_out.get())
79
+ cursor.exec
80
+ assert_equal(i, cursor[:day])
85
81
  end
86
82
  end
87
83
 
88
84
  def test_get_day
89
- @stmt.prepare("BEGIN :time := TO_DATE('200101' || TO_CHAR(:day, 'FM00'), 'YYYYMMDD'); END;")
90
- day_in = @stmt.bindByName(":day", Fixnum)
91
- time_out = @stmt.bindByName(":time", Time)
85
+ cursor = @conn.parse("BEGIN :time := TO_DATE('200101' || TO_CHAR(:day, 'FM00'), 'YYYYMMDD'); END;")
86
+ day_in = cursor.bind_param(:day, Fixnum)
87
+ time_out = cursor.bind_param(:time, Time)
92
88
  DAY_CHECK_TARGET.each do |i|
93
89
  # set time via oracle.
94
- day_in.set(i)
95
- @stmt.execute(@svc)
90
+ cursor[:day] = i;
91
+ cursor.exec
96
92
  # check Time#day
97
- assert_equal(i, time_out.get.day)
93
+ assert_equal(i, cursor[:time].day)
98
94
  end
99
95
  end
100
96
 
101
97
  def test_set_hour
102
- @stmt.prepare("BEGIN :hour := TO_NUMBER(TO_CHAR(:time, 'HH24'), '99'); END;")
103
- time_in = @stmt.bindByName(":time", Time)
104
- hour_out = @stmt.bindByName(":hour", Fixnum)
98
+ cursor = @conn.parse("BEGIN :hour := TO_NUMBER(TO_CHAR(:time, 'HH24'), '99'); END;")
99
+ cursor.bind_param(:time, Time)
100
+ cursor.bind_param(:hour, Fixnum)
105
101
  HOUR_CHECK_TARGET.each do |i|
106
102
  # set hour
107
- time = Time.local(2001, 1, 1, i)
103
+ cursor[:time] = Time.local(2001, 1, 1, i)
108
104
  # check result via oracle.
109
- time_in.set(time)
110
- @stmt.execute(@svc)
111
- assert_equal(i, hour_out.get())
105
+ cursor.exec
106
+ assert_equal(i, cursor[:hour])
112
107
  end
113
108
  end
114
109
 
115
110
  def test_get_hour
116
- @stmt.prepare("BEGIN :time := TO_DATE(TO_CHAR(:hour, '99'), 'HH24'); END;")
117
- hour_in = @stmt.bindByName(":hour", Fixnum)
118
- time_out = @stmt.bindByName(":time", Time)
111
+ cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:hour, '99'), 'HH24'); END;")
112
+ cursor.bind_param(:hour, Fixnum)
113
+ cursor.bind_param(:time, Time)
119
114
  HOUR_CHECK_TARGET.each do |i|
120
115
  # set time via oracle.
121
- hour_in.set(i)
122
- @stmt.execute(@svc)
116
+ cursor[:hour] = i
117
+ cursor.exec
123
118
  # check Time#hour
124
- assert_equal(i, time_out.get.hour)
119
+ assert_equal(i, cursor[:time].hour)
125
120
  end
126
121
  end
127
122
 
128
123
  def test_set_min
129
- @stmt.prepare("BEGIN :min := TO_NUMBER(TO_CHAR(:time, 'MI'), '99'); END;")
130
- time_in = @stmt.bindByName(":time", Time)
131
- min_out = @stmt.bindByName(":min", Fixnum)
124
+ cursor = @conn.parse("BEGIN :min := TO_NUMBER(TO_CHAR(:time, 'MI'), '99'); END;")
125
+ cursor.bind_param(:time, Time)
126
+ cursor.bind_param(:min, Fixnum)
132
127
  MIN_CHECK_TARGET.each do |i|
133
128
  # set min
134
- time = Time.local(2001, 1, 1, 0, i)
129
+ cursor[:time] = Time.local(2001, 1, 1, 0, i)
135
130
  # check result via oracle.
136
- time_in.set(time)
137
- @stmt.execute(@svc)
138
- assert_equal(i, min_out.get())
131
+ cursor.exec
132
+ assert_equal(i, cursor[:min])
139
133
  end
140
134
  end
141
135
 
142
136
  def test_get_min
143
- @stmt.prepare("BEGIN :time := TO_DATE(TO_CHAR(:min, '99'), 'MI'); END;")
144
- min_in = @stmt.bindByName(":min", Fixnum)
145
- time_out = @stmt.bindByName(":time", Time)
137
+ cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:min, '99'), 'MI'); END;")
138
+ cursor.bind_param(:min, Fixnum)
139
+ cursor.bind_param(:time, Time)
146
140
  MIN_CHECK_TARGET.each do |i|
147
141
  # set time via oracle.
148
- min_in.set(i)
149
- @stmt.execute(@svc)
142
+ cursor[:min] = i;
143
+ cursor.exec
150
144
  # check Time#min
151
- assert_equal(i, time_out.get.min)
145
+ assert_equal(i, cursor[:time].min)
152
146
  end
153
147
  end
154
148
 
155
149
  def test_set_sec
156
- @stmt.prepare("BEGIN :sec := TO_NUMBER(TO_CHAR(:time, 'SS'), '99'); END;")
157
- time_in = @stmt.bindByName(":time", Time)
158
- sec_out = @stmt.bindByName(":sec", Fixnum)
150
+ cursor = @conn.parse("BEGIN :sec := TO_NUMBER(TO_CHAR(:time, 'SS'), '99'); END;")
151
+ cursor.bind_param(:time, Time)
152
+ cursor.bind_param(:sec, Fixnum)
159
153
  SEC_CHECK_TARGET.each do |i|
160
154
  # set sec
161
- time = Time.local(2001, 1, 1, 0, 0, i)
155
+ cursor[:time] = Time.local(2001, 1, 1, 0, 0, i)
162
156
  # check result via oracle.
163
- time_in.set(time)
164
- @stmt.execute(@svc)
165
- assert_equal(i, sec_out.get())
157
+ cursor.exec
158
+ assert_equal(i, cursor[:sec])
166
159
  end
167
160
  end
168
161
 
169
162
  def test_get_sec
170
- @stmt.prepare("BEGIN :time := TO_DATE(TO_CHAR(:sec, '99'), 'SS'); END;")
171
- sec_in = @stmt.bindByName(":sec", Fixnum)
172
- time_out = @stmt.bindByName(":time", Time)
163
+ cursor = @conn.parse("BEGIN :time := TO_DATE(TO_CHAR(:sec, '99'), 'SS'); END;")
164
+ cursor.bind_param(:sec, Fixnum)
165
+ cursor.bind_param(:time, Time)
173
166
  SEC_CHECK_TARGET.each do |i|
174
167
  # set time via oracle.
175
- sec_in.set(i)
176
- @stmt.execute(@svc)
168
+ cursor[:sec] = i
169
+ cursor.exec
177
170
  # check Time#sec
178
- assert_equal(i, time_out.get.sec)
171
+ assert_equal(i, cursor[:time].sec)
179
172
  end
180
173
  end
181
174
 
182
175
  def teardown
183
- @stmt.free()
184
- @svc.logoff()
185
- @env.free()
176
+ @conn.logoff
186
177
  end
187
178
  end
188
-
189
- if $0 == __FILE__
190
- RUNIT::CUI::TestRunner.run(TestBindTime.suite())
191
- end