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
@@ -1,18 +1,79 @@
1
1
  require 'oci8'
2
- require 'runit/testcase'
3
- require 'runit/cui/testrunner'
2
+ require 'test/unit'
4
3
  require File.dirname(__FILE__) + '/config'
5
4
 
6
- class TestOCI8 < RUNIT::TestCase
5
+ class TestOCI8 < Test::Unit::TestCase
7
6
 
8
7
  def setup
9
- @conn = get_oci_connection()
8
+ @conn = get_oci8_connection
10
9
  end
11
10
 
12
11
  def teardown
13
12
  @conn.logoff
14
13
  end
15
14
 
15
+ def test_rename
16
+ drop_table('test_table')
17
+ drop_table('test_rename_table')
18
+ sql = <<-EOS
19
+ CREATE TABLE test_rename_table
20
+ (C CHAR(10) NOT NULL)
21
+ EOS
22
+ @conn.exec(sql)
23
+ @conn.exec("RENAME test_rename_table TO test_table")
24
+ drop_table('test_rename_table')
25
+ end
26
+
27
+ # USE_DYNAMIC_FETCH doesn't work well...
28
+ # This test is disabled.
29
+ def _test_long_type
30
+ drop_table('test_table')
31
+ @conn.exec('CREATE TABLE test_table (id number(38), lng long)')
32
+ test_data1 = 'a' * 70000
33
+ test_data2 = 'b' * 3000
34
+ test_data3 = nil
35
+ test_data4 = 'c' * 70000
36
+ @conn.exec('insert into test_table values (:1, :2)', 1, test_data1)
37
+ @conn.exec('insert into test_table values (:1, :2)', 2, [test_data2, :long])
38
+ @conn.exec('insert into test_table values (:1, :2)', 3, [nil, :long])
39
+ @conn.exec('insert into test_table values (:1, :2)', 4, [test_data4, :long])
40
+
41
+ [8000, 65535, 65536, 80000].each do |read_len|
42
+ @conn.long_read_len = read_len
43
+ cursor = @conn.parse('SELECT lng from test_table order by id')
44
+ cursor.exec
45
+ assert_equal(test_data1, cursor.fetch[0])
46
+ assert_equal(test_data2, cursor.fetch[0])
47
+ assert_equal(test_data3, cursor.fetch[0])
48
+ assert_equal(test_data4, cursor.fetch[0])
49
+ cursor.close
50
+ end
51
+ drop_table('test_table')
52
+ end
53
+
54
+ def test_long_type
55
+ @conn.long_read_len = 80000
56
+ drop_table('test_table')
57
+ @conn.exec('CREATE TABLE test_table (id number(38), lng long)')
58
+ test_data1 = 'a' * 70000
59
+ test_data2 = 'b' * 3000
60
+ test_data3 = nil
61
+ test_data4 = 'c' * 70000
62
+ @conn.exec('insert into test_table values (:1, :2)', 1, test_data1)
63
+ @conn.exec('insert into test_table values (:1, :2)', 2, [test_data2, :long])
64
+ @conn.exec('insert into test_table values (:1, :2)', 3, [nil, :long])
65
+ @conn.exec('insert into test_table values (:1, :2)', 4, [test_data4, :long])
66
+
67
+ cursor = @conn.parse('SELECT lng from test_table order by id')
68
+ cursor.exec
69
+ assert_equal(test_data1, cursor.fetch[0])
70
+ assert_equal(test_data2, cursor.fetch[0])
71
+ assert_equal(test_data3, cursor.fetch[0])
72
+ assert_equal(test_data4, cursor.fetch[0])
73
+ cursor.close
74
+ drop_table('test_table')
75
+ end
76
+
16
77
  def test_select
17
78
  drop_table('test_table')
18
79
  sql = <<-EOS
@@ -43,7 +104,7 @@ EOS
43
104
  cursor = @conn.parse("SELECT * FROM test_table ORDER BY c")
44
105
  cursor.define(5, Time) # define 5th column as Time
45
106
  cursor.define(6, Date) # define 6th column as Date
46
- cursor.define(7, DateTime) if defined? DateTime # define 7th column as DateTime
107
+ cursor.define(7, DateTime) # define 7th column as DateTime
47
108
  cursor.define(8, Integer) # define 8th column as Integer
48
109
  cursor.define(9, Bignum) # define 9th column as Bignum
49
110
  cursor.exec
@@ -59,11 +120,13 @@ EOS
59
120
  assert_nil(rv[5])
60
121
  assert_nil(rv[6])
61
122
  else
62
- dt = OraDate.new(2000 + i, 8, 3, 23, 59, 59)
63
- assert_equal(dt, rv[3])
64
- assert_equal(dt.to_time, rv[4])
65
- assert_equal(dt.to_date, rv[5])
66
- assert_equal(dt.to_datetime, rv[6]) if defined? DateTime
123
+ tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
124
+ dt = Date.civil(2000 + i, 8, 3)
125
+ dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
126
+ assert_equal(tm, rv[3])
127
+ assert_equal(tm, rv[4])
128
+ assert_equal(dt, rv[5])
129
+ assert_equal(dttm, rv[6])
67
130
  end
68
131
  assert_equal(i * 11111111111, rv[7])
69
132
  assert_equal(i * 10000000000, rv[8])
@@ -83,17 +146,19 @@ EOS
83
146
  assert_nil(row['D3'])
84
147
  assert_nil(row['D4'])
85
148
  else
86
- dt = OraDate.new(2000 + i, 8, 3, 23, 59, 59)
87
- assert_equal(dt, row['D1'])
88
- assert_equal(dt.to_time, row['D2'])
89
- assert_equal(dt.to_date, row['D3'])
90
- assert_equal(dt.to_datetime, row['D4']) if defined? DateTime
149
+ tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
150
+ dt = Date.civil(2000 + i, 8, 3)
151
+ dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
152
+ assert_equal(tm, row['D1'])
153
+ assert_equal(tm, row['D2'])
154
+ assert_equal(dt, row['D3'])
155
+ assert_equal(dttm, row['D4'])
91
156
  end
92
157
  assert_equal(i * 11111111111, row['INT'])
93
158
  assert_equal(i * 10000000000, row['BIGNUM'])
94
159
  i += 1
95
160
  end
96
- assert_equal(i, 11)
161
+ assert_equal(11, i)
97
162
 
98
163
  cursor.close
99
164
  drop_table('test_table')
@@ -127,7 +192,7 @@ EOS
127
192
  end
128
193
  cursor.close
129
194
  plsql = @conn.parse("BEGIN OPEN :cursor FOR SELECT * FROM test_table ORDER BY c; END;")
130
- plsql.bind_param(':cursor', OCI8::Cursor)
195
+ plsql.bind_param(':cursor', nil, OCI8::Cursor)
131
196
  plsql.exec
132
197
  cursor = plsql[':cursor']
133
198
  cursor.define(5, Time) # define 5th column as Time
@@ -145,10 +210,12 @@ EOS
145
210
  assert_nil(rv[4])
146
211
  assert_nil(rv[5])
147
212
  else
148
- dt = OraDate.new(2000 + i, 8, 3, 23, 59, 59)
149
- assert_equal(dt, rv[3])
150
- assert_equal(dt.to_time, rv[4])
151
- assert_equal(dt.to_date, rv[5])
213
+ dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
214
+ tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
215
+ dt = Date.civil(2000 + i, 8, 3)
216
+ assert_equal(tm, rv[3])
217
+ assert_equal(tm, rv[4])
218
+ assert_equal(dt, rv[5])
152
219
  end
153
220
  assert_equal(i, rv[6])
154
221
  assert_equal(i, rv[7])
@@ -197,42 +264,44 @@ EOS
197
264
  drop_table('test_table')
198
265
  end
199
266
 
200
- if $oracle_version >= 1000
267
+ def test_binary_float
268
+ return if $oracle_version < OCI8::ORAVER_10_1
269
+
201
270
  # Oracle 10g or upper
202
- def test_binary_float
203
- cursor = @conn.parse("select CAST(:1 AS BINARY_FLOAT), CAST(:2 AS BINARY_DOUBLE) from dual")
204
- bind_val = -1.0
205
- cursor.bind_param(1, 10.0, OCI8::SQLT_IBDOUBLE)
206
- cursor.bind_param(2, nil, OCI8::SQLT_IBDOUBLE)
207
- while bind_val < 10.0
208
- cursor[2] = bind_val
209
- cursor.exec
210
- rv = cursor.fetch
211
- assert_equal(10.0, rv[0])
212
- assert_equal(bind_val, rv[1])
213
- bind_val += 1.234
214
- end
215
- [-1.0/0.0, # -Infinite
216
- +1.0/0.0, # +Infinite
217
- 0.0/0.0 # NaN
218
- ].each do |num|
219
- cursor[1] = num
220
- cursor[2] = num
221
- cursor.exec
222
- rv = cursor.fetch
223
- if num.nan?
224
- assert(rv[0].nan?)
225
- assert(rv[1].nan?)
226
- else
227
- assert_equal(num, rv[0])
228
- assert_equal(num, rv[1])
229
- end
271
+ cursor = @conn.parse("select CAST(:1 AS BINARY_FLOAT), CAST(:2 AS BINARY_DOUBLE) from dual")
272
+ bind_val = -1.0
273
+ cursor.bind_param(1, 10.0, :binary_double)
274
+ cursor.bind_param(2, nil, :binary_double)
275
+ while bind_val < 10.0
276
+ cursor[2] = bind_val
277
+ cursor.exec
278
+ rv = cursor.fetch
279
+ assert_equal(10.0, rv[0])
280
+ assert_equal(bind_val, rv[1])
281
+ bind_val += 1.234
282
+ end
283
+ [-1.0/0.0, # -Infinite
284
+ +1.0/0.0, # +Infinite
285
+ 0.0/0.0 # NaN
286
+ ].each do |num|
287
+ cursor[1] = num
288
+ cursor[2] = num
289
+ cursor.exec
290
+ rv = cursor.fetch
291
+ if num.nan?
292
+ assert(rv[0].nan?)
293
+ assert(rv[1].nan?)
294
+ else
295
+ assert_equal(num, rv[0])
296
+ assert_equal(num, rv[1])
230
297
  end
231
- cursor.close
232
298
  end
299
+ cursor.close
233
300
  end
234
301
 
235
302
  def test_clob_nclob_and_blob
303
+ return if OCI8::oracle_client_version < OCI8::ORAVER_8_1
304
+
236
305
  drop_table('test_table')
237
306
  sql = <<-EOS
238
307
  CREATE TABLE test_table (id number(5), C CLOB, NC NCLOB, B BLOB)
@@ -259,6 +328,7 @@ EOS
259
328
  assert_instance_of(OCI8::NCLOB, rv[2])
260
329
  assert_instance_of(OCI8::BLOB, rv[3])
261
330
  assert_equal(val, rv[1].read)
331
+ assert_equal(val.length, rv[2].size)
262
332
  assert_equal(val, rv[2].read)
263
333
  assert_equal(val, rv[3].read)
264
334
  end
@@ -266,8 +336,34 @@ EOS
266
336
  cursor.close
267
337
  drop_table('test_table')
268
338
  end
269
- end # TestOCI8
270
339
 
271
- if $0 == __FILE__
272
- RUNIT::CUI::TestRunner.run(TestOCI8.suite())
273
- end
340
+ def test_select_number
341
+ drop_table('test_table')
342
+ @conn.exec(<<EOS)
343
+ CREATE TABLE test_table (n NUMBER, n20 NUMBER(20), n14_2 NUMBER(14,2), n15_2 NUMBER(15,2), flt FLOAT)
344
+ STORAGE (
345
+ INITIAL 100k
346
+ NEXT 100k
347
+ MINEXTENTS 1
348
+ MAXEXTENTS UNLIMITED
349
+ PCTINCREASE 0)
350
+ EOS
351
+ @conn.exec(<<EOS)
352
+ INSERT INTO test_table values(12345678901234, 12345678901234567890, 123456789012.34, 1234567890123.45, 1234.5)
353
+ EOS
354
+ @conn.exec("select * from test_table") do |row|
355
+ assert_equal(row[0], 12345678901234)
356
+ assert_equal(row[1], 12345678901234567890)
357
+ assert_equal(row[2], 123456789012.34)
358
+ assert_equal(row[3], 1234567890123.45)
359
+ assert_equal(row[4], 1234.5)
360
+ assert_instance_of(OraNumber, row[0])
361
+ assert_instance_of(Bignum, row[1])
362
+ assert_instance_of(Float, row[2])
363
+ assert_instance_of(OraNumber, row[3])
364
+ assert_instance_of(Float, row[4])
365
+ end
366
+ drop_table('test_table')
367
+ end
368
+
369
+ end # TestOCI8
@@ -0,0 +1,70 @@
1
+ require 'oci8'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/config'
4
+
5
+ class TestOracleVersion < Test::Unit::TestCase
6
+
7
+ def test_init
8
+ oraver = OCI8::OracleVersion.new('8.1.6.2.3')
9
+ assert_equal(8, oraver.major)
10
+ assert_equal(1, oraver.minor)
11
+ assert_equal(6, oraver.update)
12
+ assert_equal(2, oraver.patch)
13
+ assert_equal(3, oraver.port_update)
14
+
15
+ oraver = OCI8::OracleVersion.new('8.1.6')
16
+ assert_equal(8, oraver.major)
17
+ assert_equal(1, oraver.minor)
18
+ assert_equal(6, oraver.update)
19
+ assert_equal(0, oraver.patch)
20
+ assert_equal(0, oraver.port_update)
21
+
22
+ oraver = OCI8::OracleVersion.new('10')
23
+ assert_equal(10, oraver.major)
24
+ assert_equal(0, oraver.minor)
25
+ assert_equal(0, oraver.update)
26
+ assert_equal(0, oraver.patch)
27
+ assert_equal(0, oraver.port_update)
28
+
29
+ oraver = OCI8::OracleVersion.new(0x08106203)
30
+ assert_equal(8, oraver.major)
31
+ assert_equal(1, oraver.minor)
32
+ assert_equal(6, oraver.update)
33
+ assert_equal(2, oraver.patch)
34
+ assert_equal(3, oraver.port_update)
35
+ end
36
+
37
+ def test_compare
38
+ oraver = OCI8::OracleVersion.new('8.1.6.2.3')
39
+ assert_operator(oraver, :==, OCI8::OracleVersion.new('8.1.6.2.3'))
40
+ assert_operator(oraver, :<, OCI8::OracleVersion.new('9.1.6.2.3'))
41
+ assert_operator(oraver, :<, OCI8::OracleVersion.new('8.2.6.2.3'))
42
+ assert_operator(oraver, :<, OCI8::OracleVersion.new('8.1.7.2.3'))
43
+ assert_operator(oraver, :<, OCI8::OracleVersion.new('8.1.6.3.3'))
44
+ assert_operator(oraver, :<, OCI8::OracleVersion.new('8.1.6.2.4'))
45
+ assert_operator(oraver, :>, OCI8::OracleVersion.new('7.1.6.2.3'))
46
+ assert_operator(oraver, :>, OCI8::OracleVersion.new('8.0.6.2.3'))
47
+ assert_operator(oraver, :>, OCI8::OracleVersion.new('8.1.5.2.3'))
48
+ assert_operator(oraver, :>, OCI8::OracleVersion.new('8.1.6.1.3'))
49
+ assert_operator(oraver, :>, OCI8::OracleVersion.new('8.1.6.2.2'))
50
+ end
51
+
52
+ def test_to_s
53
+ oraver = OCI8::OracleVersion.new('8.1.6.2.3')
54
+ assert_equal('8.1.6.2.3', oraver.to_s)
55
+ end
56
+
57
+ def test_to_i
58
+ oraver = OCI8::OracleVersion.new('8.1.6.2.3')
59
+ assert_equal(0x08106203, oraver.to_i)
60
+ end
61
+
62
+ def test_eql
63
+ oraver = OCI8::OracleVersion.new('8.1.6.2.3')
64
+ assert_equal(true, oraver.eql?(OCI8::OracleVersion.new('8.1.6.2.3')))
65
+ assert_equal(false, oraver.eql?(OCI8::OracleVersion.new('8.2.6.2.3')))
66
+ assert_equal(false, oraver.eql?('8.1.6.2.3'))
67
+ end
68
+ end
69
+
70
+ Test::Unit::AutoRunner.run() if $0 == __FILE__
@@ -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 TestOraDate < RUNIT::TestCase
6
+ class TestOraDate < Test::Unit::TestCase
8
7
 
9
8
  YEAR_CHECK_TARGET = [-4712, -1, 1, 1192, 1868, 2002, 9999]
10
9
  MONTH_CHECK_TARGET = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
@@ -14,7 +13,7 @@ class TestOraDate < RUNIT::TestCase
14
13
  SECOND_CHECK_TARGET = [0, 15, 30, 45, 59]
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 check_oradate(target, year, month, day, hour, minute, second)
@@ -31,170 +30,170 @@ class TestOraDate < RUNIT::TestCase
31
30
  end
32
31
 
33
32
  def test_set_year
34
- @stmt.prepare("BEGIN :year := TO_NUMBER(TO_CHAR(:date, 'SYYYY'), '9999'); END;")
35
- date_in = @stmt.bindByName(":date", OraDate)
36
- year_out = @stmt.bindByName(":year", Fixnum)
33
+ cursor = @conn.parse("BEGIN :year := TO_NUMBER(TO_CHAR(:date, 'SYYYY'), '9999'); END;")
34
+ cursor.bind_param(:date, OraDate)
35
+ cursor.bind_param(:year, Fixnum)
37
36
  date = OraDate.new()
38
37
  YEAR_CHECK_TARGET.each do |i|
39
38
  # set year
40
39
  date.year = i
41
40
  # check result via oracle.
42
- date_in.set(date)
43
- @stmt.execute(@svc)
44
- assert_equal(i, year_out.get())
41
+ cursor[:date] = date
42
+ cursor.exec
43
+ assert_equal(i, cursor[:year])
45
44
  end
46
45
  end
47
46
 
48
47
  def test_get_year
49
- @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:year, '0999'), 'SYYYY'); END;")
50
- year_in = @stmt.bindByName(":year", Fixnum)
51
- date_out = @stmt.bindByName(":date", OraDate)
48
+ cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:year, '0999'), 'SYYYY'); END;")
49
+ cursor.bind_param(:year, Fixnum)
50
+ cursor.bind_param(:date, OraDate)
52
51
  YEAR_CHECK_TARGET.each do |i|
53
52
  # set date via oracle.
54
- year_in.set(i)
55
- @stmt.execute(@svc)
53
+ cursor[:year] = i
54
+ cursor.exec
56
55
  # check OraDate#year
57
- assert_equal(i, date_out.get.year)
56
+ assert_equal(i, cursor[:date].year)
58
57
  end
59
58
  end
60
59
 
61
60
  def test_set_month
62
- @stmt.prepare("BEGIN :month := TO_NUMBER(TO_CHAR(:date, 'MM'), '99'); END;")
63
- date_in = @stmt.bindByName(":date", OraDate)
64
- month_out = @stmt.bindByName(":month", Fixnum)
61
+ cursor = @conn.parse("BEGIN :month := TO_NUMBER(TO_CHAR(:date, 'MM'), '99'); END;")
62
+ cursor.bind_param(:date, OraDate)
63
+ cursor.bind_param(:month, Fixnum)
65
64
  date = OraDate.new()
66
65
  MONTH_CHECK_TARGET.each do |i|
67
66
  # set month
68
67
  date.month = i
69
68
  # check result via oracle.
70
- date_in.set(date)
71
- @stmt.execute(@svc)
72
- assert_equal(i, month_out.get())
69
+ cursor[:date] = date
70
+ cursor.exec
71
+ assert_equal(i, cursor[:month])
73
72
  end
74
73
  end
75
74
 
76
75
  def test_get_month
77
- @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:month, '99'), 'MM'); END;")
78
- month_in = @stmt.bindByName(":month", Fixnum)
79
- date_out = @stmt.bindByName(":date", OraDate)
76
+ cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:month, '99'), 'MM'); END;")
77
+ cursor.bind_param(:month, Fixnum)
78
+ cursor.bind_param(:date, OraDate)
80
79
  MONTH_CHECK_TARGET.each do |i|
81
80
  # set date via oracle.
82
- month_in.set(i)
83
- @stmt.execute(@svc)
81
+ cursor[:month] = i
82
+ cursor.exec
84
83
  # check OraDate#month
85
- assert_equal(i, date_out.get.month)
84
+ assert_equal(i, cursor[:date].month)
86
85
  end
87
86
  end
88
87
 
89
88
  def test_set_day
90
- @stmt.prepare("BEGIN :day := TO_NUMBER(TO_CHAR(:date, 'DD'), '99'); END;")
91
- date_in = @stmt.bindByName(":date", OraDate)
92
- day_out = @stmt.bindByName(":day", Fixnum)
89
+ cursor = @conn.parse("BEGIN :day := TO_NUMBER(TO_CHAR(:date, 'DD'), '99'); END;")
90
+ cursor.bind_param(:date, OraDate)
91
+ cursor.bind_param(:day, Fixnum)
93
92
  date = OraDate.new()
94
93
  DAY_CHECK_TARGET.each do |i|
95
94
  # set day
96
95
  date.day = i
97
96
  # check result via oracle.
98
- date_in.set(date)
99
- @stmt.execute(@svc)
100
- assert_equal(i, day_out.get())
97
+ cursor[:date] = date
98
+ cursor.exec
99
+ assert_equal(i, cursor[:day])
101
100
  end
102
101
  end
103
102
 
104
103
  def test_get_day
105
- @stmt.prepare("BEGIN :date := TO_DATE('200101' || TO_CHAR(:day, 'FM00'), 'YYYYMMDD'); END;")
106
- day_in = @stmt.bindByName(":day", Fixnum)
107
- date_out = @stmt.bindByName(":date", OraDate)
104
+ cursor = @conn.parse("BEGIN :date := TO_DATE('200101' || TO_CHAR(:day, 'FM00'), 'YYYYMMDD'); END;")
105
+ cursor.bind_param(:day, Fixnum)
106
+ cursor.bind_param(:date, OraDate)
108
107
  DAY_CHECK_TARGET.each do |i|
109
108
  # set date via oracle.
110
- day_in.set(i)
111
- @stmt.execute(@svc)
109
+ cursor[:day] = i
110
+ cursor.exec
112
111
  # check OraDate#day
113
- assert_equal(i, date_out.get.day)
112
+ assert_equal(i, cursor[:date].day)
114
113
  end
115
114
  end
116
115
 
117
116
  def test_set_hour
118
- @stmt.prepare("BEGIN :hour := TO_NUMBER(TO_CHAR(:date, 'HH24'), '99'); END;")
119
- date_in = @stmt.bindByName(":date", OraDate)
120
- hour_out = @stmt.bindByName(":hour", Fixnum)
117
+ cursor = @conn.parse("BEGIN :hour := TO_NUMBER(TO_CHAR(:date, 'HH24'), '99'); END;")
118
+ cursor.bind_param(:date, OraDate)
119
+ cursor.bind_param(:hour, Fixnum)
121
120
  date = OraDate.new()
122
121
  HOUR_CHECK_TARGET.each do |i|
123
122
  # set hour
124
123
  date.hour = i
125
124
  # check result via oracle.
126
- date_in.set(date)
127
- @stmt.execute(@svc)
128
- assert_equal(i, hour_out.get())
125
+ cursor[:date] = date
126
+ cursor.exec
127
+ assert_equal(i, cursor[:hour])
129
128
  end
130
129
  end
131
130
 
132
131
  def test_get_hour
133
- @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:hour, '99'), 'HH24'); END;")
134
- hour_in = @stmt.bindByName(":hour", Fixnum)
135
- date_out = @stmt.bindByName(":date", OraDate)
132
+ cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:hour, '99'), 'HH24'); END;")
133
+ cursor.bind_param(:hour, Fixnum)
134
+ cursor.bind_param(:date, OraDate)
136
135
  HOUR_CHECK_TARGET.each do |i|
137
136
  # set date via oracle.
138
- hour_in.set(i)
139
- @stmt.execute(@svc)
137
+ cursor[:hour] = i
138
+ cursor.exec
140
139
  # check OraDate#hour
141
- assert_equal(i, date_out.get.hour)
140
+ assert_equal(i, cursor[:date].hour)
142
141
  end
143
142
  end
144
143
 
145
144
  def test_set_minute
146
- @stmt.prepare("BEGIN :minute := TO_NUMBER(TO_CHAR(:date, 'MI'), '99'); END;")
147
- date_in = @stmt.bindByName(":date", OraDate)
148
- minute_out = @stmt.bindByName(":minute", Fixnum)
145
+ cursor = @conn.parse("BEGIN :minute := TO_NUMBER(TO_CHAR(:date, 'MI'), '99'); END;")
146
+ cursor.bind_param(:date, OraDate)
147
+ cursor.bind_param(:minute, Fixnum)
149
148
  date = OraDate.new()
150
149
  MINUTE_CHECK_TARGET.each do |i|
151
150
  # set minute
152
151
  date.minute = i
153
152
  # check result via oracle.
154
- date_in.set(date)
155
- @stmt.execute(@svc)
156
- assert_equal(i, minute_out.get())
153
+ cursor[:date] = date
154
+ cursor.exec
155
+ assert_equal(i, cursor[:minute])
157
156
  end
158
157
  end
159
158
 
160
159
  def test_get_minute
161
- @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:minute, '99'), 'MI'); END;")
162
- minute_in = @stmt.bindByName(":minute", Fixnum)
163
- date_out = @stmt.bindByName(":date", OraDate)
160
+ cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:minute, '99'), 'MI'); END;")
161
+ cursor.bind_param(:minute, Fixnum)
162
+ cursor.bind_param(:date, OraDate)
164
163
  MINUTE_CHECK_TARGET.each do |i|
165
164
  # set date via oracle.
166
- minute_in.set(i)
167
- @stmt.execute(@svc)
165
+ cursor[:minute] = i
166
+ cursor.exec
168
167
  # check OraDate#minute
169
- assert_equal(i, date_out.get.minute)
168
+ assert_equal(i, cursor[:date].minute)
170
169
  end
171
170
  end
172
171
 
173
172
  def test_set_second
174
- @stmt.prepare("BEGIN :second := TO_NUMBER(TO_CHAR(:date, 'SS'), '99'); END;")
175
- date_in = @stmt.bindByName(":date", OraDate)
176
- second_out = @stmt.bindByName(":second", Fixnum)
173
+ cursor = @conn.parse("BEGIN :second := TO_NUMBER(TO_CHAR(:date, 'SS'), '99'); END;")
174
+ cursor.bind_param(:date, OraDate)
175
+ cursor.bind_param(:second, Fixnum)
177
176
  date = OraDate.new()
178
177
  SECOND_CHECK_TARGET.each do |i|
179
178
  # set second
180
179
  date.second = i
181
180
  # check result via oracle.
182
- date_in.set(date)
183
- @stmt.execute(@svc)
184
- assert_equal(i, second_out.get())
181
+ cursor[:date] = date
182
+ cursor.exec
183
+ assert_equal(i, cursor[:second])
185
184
  end
186
185
  end
187
186
 
188
187
  def test_get_second
189
- @stmt.prepare("BEGIN :date := TO_DATE(TO_CHAR(:second, '99'), 'SS'); END;")
190
- second_in = @stmt.bindByName(":second", Fixnum)
191
- date_out = @stmt.bindByName(":date", OraDate)
188
+ cursor = @conn.parse("BEGIN :date := TO_DATE(TO_CHAR(:second, '99'), 'SS'); END;")
189
+ cursor.bind_param(:second, Fixnum)
190
+ cursor.bind_param(:date, OraDate)
192
191
  SECOND_CHECK_TARGET.each do |i|
193
192
  # set date via oracle.
194
- second_in.set(i)
195
- @stmt.execute(@svc)
193
+ cursor[:second] = i
194
+ cursor.exec
196
195
  # check OraDate#second
197
- assert_equal(i, date_out.get.second)
196
+ assert_equal(i, cursor[:date].second)
198
197
  end
199
198
  end
200
199
 
@@ -252,12 +251,6 @@ class TestOraDate < RUNIT::TestCase
252
251
  end
253
252
 
254
253
  def teardown
255
- @stmt.free()
256
- @svc.logoff()
257
- @env.free()
254
+ @conn.logoff
258
255
  end
259
256
  end
260
-
261
- if $0 == __FILE__
262
- RUNIT::CUI::TestRunner.run(TestOraDate.suite())
263
- end