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.
Files changed (89) hide show
  1. data/ChangeLog +1254 -390
  2. data/Makefile +10 -13
  3. data/README +56 -385
  4. data/VERSION +1 -1
  5. data/dist-files +26 -27
  6. data/ext/oci8/.document +1 -0
  7. data/ext/oci8/MANIFEST +0 -4
  8. data/ext/oci8/apiwrap.c.tmpl +172 -0
  9. data/ext/oci8/apiwrap.h.tmpl +61 -0
  10. data/ext/oci8/apiwrap.rb +91 -0
  11. data/ext/oci8/apiwrap.yml +1243 -0
  12. data/ext/oci8/attr.c +124 -384
  13. data/ext/oci8/bind.c +472 -164
  14. data/ext/oci8/encoding.c +196 -0
  15. data/ext/oci8/env.c +84 -253
  16. data/ext/oci8/error.c +196 -127
  17. data/ext/oci8/extconf.rb +82 -59
  18. data/ext/oci8/lob.c +710 -370
  19. data/ext/oci8/metadata.c +359 -0
  20. data/ext/oci8/object.c +622 -0
  21. data/ext/oci8/oci8.c +577 -161
  22. data/ext/oci8/oci8.h +354 -258
  23. data/ext/oci8/oci8lib.c +493 -0
  24. data/ext/oci8/ocidatetime.c +473 -0
  25. data/ext/oci8/ocinumber.c +1123 -24
  26. data/ext/oci8/oraconf.rb +72 -106
  27. data/ext/oci8/oradate.c +511 -321
  28. data/ext/oci8/stmt.c +752 -572
  29. data/ext/oci8/win32.c +131 -0
  30. data/ext/oci8/xmldb.c +383 -0
  31. data/lib/.document +2 -0
  32. data/lib/dbd/OCI8.rb +2 -17
  33. data/lib/oci8.rb.in +41 -1622
  34. data/lib/oci8/.document +5 -0
  35. data/lib/oci8/compat.rb +108 -0
  36. data/lib/oci8/datetime.rb +489 -0
  37. data/lib/oci8/encoding-init.rb +40 -0
  38. data/lib/oci8/encoding.yml +537 -0
  39. data/lib/oci8/metadata.rb +2077 -0
  40. data/lib/oci8/object.rb +548 -0
  41. data/lib/oci8/oci8.rb +773 -0
  42. data/lib/oci8/oracle_version.rb +144 -0
  43. data/metaconfig +3 -3
  44. data/ruby-oci8.gemspec +5 -5
  45. data/setup.rb +4 -4
  46. data/test/config.rb +64 -84
  47. data/test/test_all.rb +14 -21
  48. data/test/test_array_dml.rb +317 -0
  49. data/test/test_bind_raw.rb +18 -25
  50. data/test/test_bind_time.rb +78 -91
  51. data/test/test_break.rb +37 -35
  52. data/test/test_clob.rb +33 -89
  53. data/test/test_connstr.rb +5 -4
  54. data/test/test_datetime.rb +469 -0
  55. data/test/test_dbi.rb +99 -60
  56. data/test/test_dbi_clob.rb +3 -8
  57. data/test/test_metadata.rb +65 -51
  58. data/test/test_oci8.rb +151 -55
  59. data/test/test_oracle_version.rb +70 -0
  60. data/test/test_oradate.rb +76 -83
  61. data/test/test_oranumber.rb +405 -71
  62. data/test/test_rowid.rb +6 -11
  63. metadata +31 -32
  64. data/NEWS +0 -420
  65. data/ext/oci8/const.c +0 -165
  66. data/ext/oci8/define.c +0 -53
  67. data/ext/oci8/describe.c +0 -81
  68. data/ext/oci8/descriptor.c +0 -39
  69. data/ext/oci8/handle.c +0 -273
  70. data/ext/oci8/oranumber.c +0 -445
  71. data/ext/oci8/param.c +0 -37
  72. data/ext/oci8/server.c +0 -182
  73. data/ext/oci8/session.c +0 -99
  74. data/ext/oci8/svcctx.c +0 -238
  75. data/ruby-oci8.spec +0 -62
  76. data/support/README +0 -4
  77. data/support/runit/assert.rb +0 -281
  78. data/support/runit/cui/testrunner.rb +0 -101
  79. data/support/runit/error.rb +0 -4
  80. data/support/runit/method_mappable.rb +0 -20
  81. data/support/runit/robserver.rb +0 -25
  82. data/support/runit/setuppable.rb +0 -15
  83. data/support/runit/teardownable.rb +0 -16
  84. data/support/runit/testcase.rb +0 -113
  85. data/support/runit/testfailure.rb +0 -25
  86. data/support/runit/testresult.rb +0 -121
  87. data/support/runit/testsuite.rb +0 -43
  88. data/support/runit/version.rb +0 -3
  89. data/test/test_describe.rb +0 -137
@@ -0,0 +1,317 @@
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
+ STORAGE (
27
+ INITIAL 4k
28
+ NEXT 4k
29
+ MINEXTENTS 1
30
+ MAXEXTENTS UNLIMITED
31
+ PCTINCREASE 0)
32
+ EOS
33
+ @conn.exec(sql)
34
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:C, :V, :N, :D, :INT, :BIGNUM)")
35
+ max_array_size = 3
36
+ cursor.max_array_size= max_array_size
37
+
38
+ cursor.bind_param_array(1, nil, String)
39
+ cursor.bind_param_array(2, nil ,String)
40
+ cursor.bind_param_array(3, nil, Fixnum)
41
+ cursor.bind_param_array(4, nil, OraDate)
42
+ cursor.bind_param_array(5, nil, Integer)
43
+ cursor.bind_param_array(6, nil, Bignum)
44
+
45
+ c_arr = Array.new
46
+ v_arr = Array.new
47
+ n_arr = Array.new
48
+ d_arr = Array.new
49
+ int_arr = Array.new
50
+ bignum_arr = Array.new
51
+
52
+ 1.upto(30) do |i|
53
+ c_arr << format("%10d", i * 10)
54
+ v_arr << i.to_s
55
+ n_arr << i
56
+ d_arr << OraDate.new(2000 + i, 12, 24, 23, 59, 59)
57
+ int_arr << i * 11111111111
58
+ bignum_arr << i * 10000000000
59
+
60
+ if i%max_array_size == 0
61
+ cursor[1] = c_arr
62
+ cursor[2] = v_arr
63
+ cursor[3] = n_arr
64
+ cursor[4] = d_arr
65
+ cursor[5] = int_arr
66
+ cursor[6] = bignum_arr
67
+
68
+ r = cursor.exec_array
69
+ assert_equal(max_array_size, r)
70
+ c_arr.clear
71
+ v_arr.clear
72
+ n_arr.clear
73
+ d_arr.clear
74
+ int_arr.clear
75
+ bignum_arr.clear
76
+ end
77
+ end
78
+ cursor.close
79
+
80
+ cursor = @conn.parse("SELECT * FROM test_table ORDER BY c")
81
+ cursor.define(5, Integer)
82
+ cursor.define(6, Bignum)
83
+ cursor.exec
84
+ assert_equal(["C","V","N","D","INT","BIGNUM"], cursor.get_col_names)
85
+ 1.upto(30) do |i|
86
+ rv = cursor.fetch
87
+ assert_equal(format("%10d", i * 10), rv[0])
88
+ assert_equal(i.to_s, rv[1])
89
+ assert_equal(i, rv[2])
90
+ tm = Time.local(2000 + i, 12, 24, 23, 59, 59)
91
+ assert_equal(tm, rv[3])
92
+ assert_equal(i * 11111111111, rv[4])
93
+ assert_equal(i * 10000000000, rv[5])
94
+ end
95
+ assert_nil(cursor.fetch)
96
+ drop_table('test_table')
97
+ end
98
+
99
+ # Raise error when binding arrays are not the same size
100
+ def test_array_insert2
101
+ drop_table('test_table')
102
+ sql = <<-EOS
103
+ CREATE TABLE test_table
104
+ (N NUMBER(10, 2) NOT NULL,
105
+ V VARCHAR(20))
106
+ EOS
107
+ @conn.exec(sql)
108
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
109
+ max_array_size = 10
110
+ cursor.max_array_size = max_array_size
111
+ cursor.bind_param_array(1, nil, Fixnum)
112
+ cursor.bind_param_array(2, nil, String)
113
+ n_arr = Array.new
114
+ v_arr = Array.new
115
+ 1.upto(max_array_size) do |i|
116
+ n_arr << i
117
+ v_arr << i.to_s if i != max_array_size
118
+ end
119
+ cursor[1] = n_arr
120
+ assert_raise(RuntimeError) { cursor[2] = v_arr }
121
+ cursor.close
122
+
123
+ drop_table('test_table')
124
+ end
125
+
126
+ # All binds are clear from cursor after calling "max_array_size=",
127
+ # in that case, you have to re-bind the array parameters
128
+ # otherwise, an error will be raised.
129
+ def test_array_insert3
130
+ drop_table('test_table')
131
+ sql = <<-EOS
132
+ CREATE TABLE test_table
133
+ (N NUMBER(10, 2) NOT NULL,
134
+ V VARCHAR(20))
135
+ EOS
136
+ @conn.exec(sql)
137
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
138
+ cursor.max_array_size = 3
139
+ cursor.bind_param_array(1, [1, 2, 3])
140
+ cursor.bind_param_array(2, ['happy', 'new', 'year'])
141
+ assert_nothing_raised() { cursor.exec_array }
142
+ cursor.max_array_size = 2
143
+ assert_raise(RuntimeError) { cursor.exec_array }
144
+ drop_table('test_table')
145
+ end
146
+
147
+ # The size of binding arrays are not required to be same as max_array_size. The
148
+ # only requirement is that they should be the same size, and the size will be
149
+ # used as execution count for OCIStmtExecute.
150
+ def test_array_insert4
151
+ drop_table('test_table')
152
+ sql = <<-EOS
153
+ CREATE TABLE test_table
154
+ (N NUMBER(10, 2) NOT NULL,
155
+ V VARCHAR(20))
156
+ EOS
157
+ @conn.exec(sql)
158
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
159
+ max_array_size = 4
160
+ cursor.max_array_size = max_array_size
161
+ cursor.bind_param_array(1, nil, Fixnum)
162
+ cursor.bind_param_array(2, nil, String)
163
+ n_arr = Array.new
164
+ v_arr = Array.new
165
+ 1.upto( max_array_size - 1 ) do |i|
166
+ n_arr << i
167
+ v_arr << i.to_s
168
+ end
169
+ cursor[1] = n_arr
170
+ cursor[2] = v_arr
171
+ assert_nothing_raised() { cursor.exec_array }
172
+ cursor.close
173
+
174
+ cursor = @conn.parse("SELECT * FROM test_table ORDER BY N")
175
+ cursor.exec
176
+ 1.upto( max_array_size - 1 ) do |i|
177
+ rv = cursor.fetch
178
+ assert_equal(i, rv[0])
179
+ assert_equal(i.to_s, rv[1])
180
+ end
181
+ assert_nil(cursor.fetch)
182
+ cursor.close
183
+ drop_table('test_table')
184
+ end
185
+
186
+ # Inserting "nil" elements with array dml raises an error
187
+ def test_array_insert5
188
+ drop_table('test_table')
189
+ sql = <<-EOS
190
+ CREATE TABLE test_table
191
+ (N NUMBER(10, 2),
192
+ V VARCHAR(20))
193
+ EOS
194
+ @conn.exec(sql)
195
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
196
+ max_array_size = 3
197
+ cursor.max_array_size = max_array_size
198
+ cursor.bind_param_array(1, nil, Fixnum)
199
+ cursor.bind_param_array(2, nil, String)
200
+ assert_raise(RuntimeError) { cursor.exec_array }
201
+ cursor.close
202
+ drop_table('test_table')
203
+ end
204
+
205
+ # delete with array bindings
206
+ def test_array_delete
207
+ drop_table('test_table')
208
+ sql = <<-EOS
209
+ CREATE TABLE test_table
210
+ (N NUMBER(10, 2),
211
+ V VARCHAR(20))
212
+ EOS
213
+ @conn.exec(sql)
214
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
215
+ max_array_size = 10
216
+ cursor.max_array_size = max_array_size
217
+ n_arr = Array.new
218
+ v_arr = Array.new
219
+ 1.upto( max_array_size) do |i|
220
+ n_arr << i
221
+ v_arr << i.to_s
222
+ end
223
+ cursor.bind_param_array(1, nil, Fixnum)
224
+ cursor.bind_param_array(2, nil, String)
225
+ cursor[1] = n_arr
226
+ cursor[2] = v_arr
227
+ cursor.exec_array
228
+ cursor.close
229
+
230
+ cursor = @conn.parse("DELETE FROM test_table WHERE N=:1")
231
+ cursor.max_array_size = max_array_size
232
+ delete_arr = Array.new
233
+ 1.upto(max_array_size) do |i|
234
+ if i%2 == 0
235
+ delete_arr << i
236
+ end
237
+ end
238
+ cursor.bind_param_array(1, nil, Fixnum)
239
+ cursor[1] = delete_arr
240
+ cursor.exec_array
241
+ cursor.close
242
+
243
+ cursor = @conn.parse("SELECT * FROM test_table ORDER BY N")
244
+ cursor.exec
245
+ 1.upto( max_array_size ) do |i|
246
+ if i%2 != 0
247
+ rv = cursor.fetch
248
+ assert_equal(rv[0], i)
249
+ assert_equal(rv[1], i.to_s)
250
+ end
251
+ end
252
+ assert_nil(cursor.fetch)
253
+ cursor.close
254
+
255
+ drop_table('test_table')
256
+ end
257
+
258
+ # update with array bindings
259
+ def test_array_update
260
+ drop_table('test_table')
261
+ sql = <<-EOS
262
+ CREATE TABLE test_table
263
+ (N NUMBER(10, 2),
264
+ V VARCHAR(20))
265
+ EOS
266
+ @conn.exec(sql)
267
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
268
+ max_array_size = 10
269
+ cursor.max_array_size = max_array_size
270
+ n_arr = Array.new
271
+ v_arr = Array.new
272
+ 1.upto( max_array_size) do |i|
273
+ n_arr << i
274
+ v_arr << i.to_s
275
+ end
276
+ cursor.bind_param_array(1, nil, Fixnum)
277
+ cursor.bind_param_array(2, nil, String)
278
+ cursor[1] = n_arr
279
+ cursor[2] = v_arr
280
+ cursor.exec_array
281
+ cursor.close
282
+
283
+ cursor = @conn.parse("UPDATE test_table SET V=:1 WHERE N=:2")
284
+ cursor.max_array_size = max_array_size
285
+ update_arr = Array.new
286
+ update_v_arr = Array.new
287
+ 1.upto(max_array_size) do |i|
288
+ if i%2 == 0
289
+ update_arr << i
290
+ update_v_arr << (i * 10).to_s
291
+ end
292
+ end
293
+ cursor.bind_param_array(1, nil, String)
294
+ cursor.bind_param_array(2, nil, Fixnum)
295
+ cursor[1] = update_v_arr
296
+ cursor[2] = update_arr
297
+ cursor.exec_array
298
+ cursor.close
299
+
300
+ cursor = @conn.parse("SELECT * FROM test_table ORDER BY N")
301
+ cursor.exec
302
+ 1.upto( max_array_size ) do |i|
303
+ rv = cursor.fetch
304
+ if i%2 != 0
305
+ assert_equal(rv[0], i)
306
+ assert_equal(rv[1], i.to_s)
307
+ else
308
+ assert_equal(rv[0], i)
309
+ assert_equal(rv[1], (i * 10).to_s)
310
+ end
311
+ end
312
+ assert_nil(cursor.fetch)
313
+
314
+ cursor.close
315
+ drop_table('test_table')
316
+ end
317
+ 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