ruby-plsql 0.4.4 → 0.5.0

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.
@@ -290,6 +290,7 @@ module PLSQL
290
290
  # insert values without autocommit
291
291
  old_autocommit = @schema.connection.autocommit?
292
292
  @schema.connection.autocommit = false if old_autocommit
293
+ tmp_table.delete
293
294
  case argument_metadata[:element][:data_type]
294
295
  when 'PL/SQL RECORD'
295
296
  values_with_index = []
@@ -401,7 +402,7 @@ module PLSQL
401
402
  @return_sql << if is_index_by_table
402
403
  "i__ := l_#{argument}.FIRST;\nLOOP\nEXIT WHEN i__ IS NULL;\n"
403
404
  else
404
- "FOR i__ IN l_#{argument}.FIRST..l_#{argument}.LAST LOOP\n"
405
+ "IF l_#{argument}.COUNT > 0 THEN\nFOR i__ IN l_#{argument}.FIRST..l_#{argument}.LAST LOOP\n"
405
406
  end
406
407
  case argument_metadata[:element][:data_type]
407
408
  when 'PL/SQL RECORD'
@@ -415,6 +416,7 @@ module PLSQL
415
416
  end
416
417
  @return_sql << "i__ := l_#{argument}.NEXT(i__);\n" if is_index_by_table
417
418
  @return_sql << "END LOOP;\n"
419
+ @return_sql << "END IF;\n" unless is_index_by_table
418
420
  @return_sql << "OPEN :#{argument} FOR SELECT #{return_fields_string} FROM #{argument_metadata[:tmp_table_name]} ORDER BY i__;\n"
419
421
  @return_sql << "DELETE FROM #{argument_metadata[:tmp_table_name]};\n"
420
422
  "l_#{argument} := " if is_return_value
data/ruby-plsql.gemspec CHANGED
@@ -1,101 +1,87 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{ruby-plsql}
8
- s.version = "0.4.4"
7
+ s.name = "ruby-plsql"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Raimonds Simanovskis"]
12
- s.date = %q{2010-10-06}
13
- s.description = %q{ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures.
14
- It could be used both for accessing Oracle PL/SQL API procedures in legacy applications
15
- as well as it could be used to create PL/SQL unit tests using Ruby testing libraries.
16
- }
17
- s.email = %q{raimonds.simanovskis@gmail.com}
12
+ s.date = "2012-04-16"
13
+ s.description = "ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures.\nIt could be used both for accessing Oracle PL/SQL API procedures in legacy applications\nas well as it could be used to create PL/SQL unit tests using Ruby testing libraries.\n"
14
+ s.email = "raimonds.simanovskis@gmail.com"
18
15
  s.extra_rdoc_files = [
19
- "README.rdoc"
16
+ "README.md"
20
17
  ]
21
18
  s.files = [
22
- ".gitignore",
23
- "Gemfile",
24
- "History.txt",
25
- "License.txt",
26
- "README.rdoc",
27
- "Rakefile",
28
- "VERSION",
29
- "lib/plsql/connection.rb",
30
- "lib/plsql/helpers.rb",
31
- "lib/plsql/jdbc_connection.rb",
32
- "lib/plsql/oci8_patches.rb",
33
- "lib/plsql/oci_connection.rb",
34
- "lib/plsql/package.rb",
35
- "lib/plsql/procedure.rb",
36
- "lib/plsql/procedure_call.rb",
37
- "lib/plsql/schema.rb",
38
- "lib/plsql/sequence.rb",
39
- "lib/plsql/sql_statements.rb",
40
- "lib/plsql/table.rb",
41
- "lib/plsql/type.rb",
42
- "lib/plsql/variable.rb",
43
- "lib/plsql/version.rb",
44
- "lib/plsql/view.rb",
45
- "lib/ruby-plsql.rb",
46
- "lib/ruby_plsql.rb",
47
- "ruby-plsql.gemspec",
48
- "spec/plsql/connection_spec.rb",
49
- "spec/plsql/package_spec.rb",
50
- "spec/plsql/procedure_spec.rb",
51
- "spec/plsql/schema_spec.rb",
52
- "spec/plsql/sequence_spec.rb",
53
- "spec/plsql/sql_statements_spec.rb",
54
- "spec/plsql/table_spec.rb",
55
- "spec/plsql/type_spec.rb",
56
- "spec/plsql/variable_spec.rb",
57
- "spec/plsql/version_spec.rb",
58
- "spec/plsql/view_spec.rb",
59
- "spec/spec.opts",
60
- "spec/spec_helper.rb"
61
- ]
62
- s.homepage = %q{http://github.com/rsim/ruby-plsql}
63
- s.rdoc_options = ["--charset=UTF-8"]
64
- s.require_paths = ["lib"]
65
- s.rubygems_version = %q{1.3.7}
66
- s.summary = %q{Ruby API for calling Oracle PL/SQL procedures.}
67
- s.test_files = [
19
+ "Gemfile",
20
+ "History.txt",
21
+ "License.txt",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/plsql/connection.rb",
26
+ "lib/plsql/helpers.rb",
27
+ "lib/plsql/jdbc_connection.rb",
28
+ "lib/plsql/oci8_patches.rb",
29
+ "lib/plsql/oci_connection.rb",
30
+ "lib/plsql/package.rb",
31
+ "lib/plsql/procedure.rb",
32
+ "lib/plsql/procedure_call.rb",
33
+ "lib/plsql/schema.rb",
34
+ "lib/plsql/sequence.rb",
35
+ "lib/plsql/sql_statements.rb",
36
+ "lib/plsql/table.rb",
37
+ "lib/plsql/type.rb",
38
+ "lib/plsql/variable.rb",
39
+ "lib/plsql/version.rb",
40
+ "lib/plsql/view.rb",
41
+ "lib/ruby-plsql.rb",
42
+ "lib/ruby_plsql.rb",
43
+ "ruby-plsql.gemspec",
68
44
  "spec/plsql/connection_spec.rb",
69
- "spec/plsql/package_spec.rb",
70
- "spec/plsql/procedure_spec.rb",
71
- "spec/plsql/schema_spec.rb",
72
- "spec/plsql/sequence_spec.rb",
73
- "spec/plsql/sql_statements_spec.rb",
74
- "spec/plsql/table_spec.rb",
75
- "spec/plsql/type_spec.rb",
76
- "spec/plsql/variable_spec.rb",
77
- "spec/plsql/version_spec.rb",
78
- "spec/plsql/view_spec.rb",
79
- "spec/spec_helper.rb"
45
+ "spec/plsql/package_spec.rb",
46
+ "spec/plsql/procedure_spec.rb",
47
+ "spec/plsql/schema_spec.rb",
48
+ "spec/plsql/sequence_spec.rb",
49
+ "spec/plsql/sql_statements_spec.rb",
50
+ "spec/plsql/table_spec.rb",
51
+ "spec/plsql/type_spec.rb",
52
+ "spec/plsql/variable_spec.rb",
53
+ "spec/plsql/version_spec.rb",
54
+ "spec/plsql/view_spec.rb",
55
+ "spec/spec.opts",
56
+ "spec/spec_helper.rb"
80
57
  ]
58
+ s.homepage = "http://github.com/rsim/ruby-plsql"
59
+ s.require_paths = ["lib"]
60
+ s.rubygems_version = "1.8.11"
61
+ s.summary = "Ruby API for calling Oracle PL/SQL procedures."
81
62
 
82
63
  if s.respond_to? :specification_version then
83
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
84
64
  s.specification_version = 3
85
65
 
86
66
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
87
- s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
88
- s.add_development_dependency(%q<activerecord>, ["= 2.3.8"])
89
- s.add_development_dependency(%q<activerecord-oracle_enhanced-adapter>, ["~> 1.3.1"])
67
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
68
+ s.add_development_dependency(%q<rspec>, ["~> 2.9"])
69
+ s.add_development_dependency(%q<activerecord>, ["~> 3.2.3"])
70
+ s.add_development_dependency(%q<activerecord-oracle_enhanced-adapter>, ["~> 1.4.1"])
71
+ s.add_development_dependency(%q<ruby-oci8>, [">= 0"])
90
72
  else
91
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
92
- s.add_dependency(%q<activerecord>, ["= 2.3.8"])
93
- s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["~> 1.3.1"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
74
+ s.add_dependency(%q<rspec>, ["~> 2.9"])
75
+ s.add_dependency(%q<activerecord>, ["~> 3.2.3"])
76
+ s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["~> 1.4.1"])
77
+ s.add_dependency(%q<ruby-oci8>, [">= 0"])
94
78
  end
95
79
  else
96
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
97
- s.add_dependency(%q<activerecord>, ["= 2.3.8"])
98
- s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["~> 1.3.1"])
80
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
81
+ s.add_dependency(%q<rspec>, ["~> 2.9"])
82
+ s.add_dependency(%q<activerecord>, ["~> 3.2.3"])
83
+ s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["~> 1.4.1"])
84
+ s.add_dependency(%q<ruby-oci8>, [">= 0"])
99
85
  end
100
86
  end
101
87
 
@@ -7,6 +7,7 @@ describe "Connection" do
7
7
  before(:all) do
8
8
  @raw_conn = get_connection
9
9
  @conn = PLSQL::Connection.create( @raw_conn )
10
+ @conn.set_time_zone
10
11
  end
11
12
 
12
13
  after(:all) do
@@ -18,28 +19,33 @@ describe "Connection" do
18
19
  end
19
20
 
20
21
  describe "create and destroy" do
22
+ before(:all) do
23
+ @raw_conn1 = get_connection
24
+ end
25
+
21
26
  before(:each) do
22
- @conn = PLSQL::Connection.create( @raw_conn )
27
+ @conn1 = PLSQL::Connection.create( @raw_conn1 )
28
+ @conn1.set_time_zone
23
29
  end
24
30
 
25
31
  it "should create connection" do
26
- @conn.raw_connection.should == @raw_conn
32
+ @conn1.raw_connection.should == @raw_conn1
27
33
  end
28
34
 
29
35
  unless defined?(JRuby)
30
36
  it "should be oci connection" do
31
- @conn.should be_oci
32
- @conn.raw_driver.should == :oci
37
+ @conn1.should be_oci
38
+ @conn1.raw_driver.should == :oci
33
39
  end
34
40
  else
35
41
  it "should be jdbc connection" do
36
- @conn.should be_jdbc
37
- @conn.raw_driver.should == :jdbc
42
+ @conn1.should be_jdbc
43
+ @conn1.raw_driver.should == :jdbc
38
44
  end
39
45
  end
40
46
 
41
47
  it "should logoff connection" do
42
- @conn.logoff.should be_true
48
+ @conn1.logoff.should be_true
43
49
  end
44
50
 
45
51
  end
@@ -153,10 +159,9 @@ describe "Connection" do
153
159
  ora_value.freeTemporary
154
160
  end
155
161
 
156
- it "should translate Ruby nil value to empty Java::OracleSql::CLOB when Java::OracleSql::CLOB type specified" do
162
+ it "should translate Ruby nil value to nil when Java::OracleSql::CLOB type specified" do
157
163
  ora_value = @conn.ruby_value_to_ora_value(nil, Java::OracleSql::CLOB)
158
- ora_value.class.should == Java::OracleSql::CLOB
159
- ora_value.isEmptyLob.should be_true
164
+ ora_value.should be_nil
160
165
  end
161
166
 
162
167
  it "should translate Oracle BigDecimal integer value to Fixnum" do
@@ -459,6 +464,7 @@ describe "Connection" do
459
464
  def reconnect_connection
460
465
  @raw_conn = get_connection
461
466
  @conn = PLSQL::Connection.create( @raw_conn )
467
+ @conn.set_time_zone
462
468
  end
463
469
 
464
470
  it "should drop current session ruby temporary tables" do
@@ -3,17 +3,9 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe "Parameter type mapping /" do
6
- before(:all) do
7
- plsql.connect! CONNECTION_PARAMS
8
- end
9
-
10
- after(:all) do
11
- plsql.logoff
12
- end
13
-
14
6
  describe "Function with string parameters" do
15
-
16
7
  before(:all) do
8
+ plsql.connect! CONNECTION_PARAMS
17
9
  plsql.execute <<-SQL
18
10
  CREATE OR REPLACE FUNCTION test_uppercase
19
11
  ( p_string VARCHAR2 )
@@ -27,6 +19,7 @@ describe "Parameter type mapping /" do
27
19
 
28
20
  after(:all) do
29
21
  plsql.execute "DROP FUNCTION test_uppercase"
22
+ plsql.logoff
30
23
  end
31
24
 
32
25
  it "should find existing procedure" do
@@ -64,8 +57,8 @@ describe "Parameter type mapping /" do
64
57
  end
65
58
 
66
59
  describe "Function with numeric parameters" do
67
-
68
60
  before(:all) do
61
+ plsql.connect! CONNECTION_PARAMS
69
62
  plsql.execute <<-SQL
70
63
  CREATE OR REPLACE FUNCTION test_sum
71
64
  ( p_num1 NUMBER, p_num2 NUMBER )
@@ -107,6 +100,7 @@ describe "Parameter type mapping /" do
107
100
  plsql.execute "DROP FUNCTION test_sum"
108
101
  plsql.execute "DROP FUNCTION test_number_1"
109
102
  plsql.execute "DROP PROCEDURE test_integers"
103
+ plsql.logoff
110
104
  end
111
105
 
112
106
  it "should process integer parameters" do
@@ -145,6 +139,7 @@ describe "Parameter type mapping /" do
145
139
  describe "Function with date parameters" do
146
140
 
147
141
  before(:all) do
142
+ plsql.connect! CONNECTION_PARAMS
148
143
  plsql.execute <<-SQL
149
144
  CREATE OR REPLACE FUNCTION test_date
150
145
  ( p_date DATE )
@@ -162,6 +157,7 @@ describe "Parameter type mapping /" do
162
157
 
163
158
  after(:all) do
164
159
  plsql.execute "DROP FUNCTION test_date"
160
+ plsql.logoff
165
161
  end
166
162
 
167
163
  it "should process Time parameters" do
@@ -210,8 +206,8 @@ describe "Parameter type mapping /" do
210
206
  end
211
207
 
212
208
  describe "Function with timestamp parameters" do
213
-
214
209
  before(:all) do
210
+ plsql.connect! CONNECTION_PARAMS
215
211
  plsql.execute <<-SQL
216
212
  CREATE OR REPLACE FUNCTION test_timestamp
217
213
  ( p_time TIMESTAMP )
@@ -225,6 +221,7 @@ describe "Parameter type mapping /" do
225
221
 
226
222
  after(:all) do
227
223
  plsql.execute "DROP FUNCTION test_timestamp"
224
+ plsql.logoff
228
225
  end
229
226
 
230
227
  it "should process timestamp parameters" do
@@ -237,6 +234,7 @@ describe "Parameter type mapping /" do
237
234
 
238
235
  describe "Procedure with output parameters" do
239
236
  before(:all) do
237
+ plsql.connect! CONNECTION_PARAMS
240
238
  plsql.execute <<-SQL
241
239
  CREATE OR REPLACE PROCEDURE test_copy
242
240
  ( p_from VARCHAR2, p_to OUT VARCHAR2, p_to_double OUT VARCHAR2 )
@@ -250,6 +248,7 @@ describe "Parameter type mapping /" do
250
248
 
251
249
  after(:all) do
252
250
  plsql.execute "DROP PROCEDURE test_copy"
251
+ plsql.logoff
253
252
  end
254
253
 
255
254
  it "should return hash with output parameters" do
@@ -272,6 +271,7 @@ describe "Parameter type mapping /" do
272
271
 
273
272
  describe "Package with procedures with same name but different argument lists" do
274
273
  before(:all) do
274
+ plsql.connect! CONNECTION_PARAMS
275
275
  plsql.execute <<-SQL
276
276
  CREATE OR REPLACE PACKAGE test_package2 IS
277
277
  FUNCTION test_procedure ( p_string VARCHAR2 )
@@ -331,6 +331,7 @@ describe "Parameter type mapping /" do
331
331
 
332
332
  after(:all) do
333
333
  plsql.execute "DROP PACKAGE test_package2"
334
+ plsql.logoff
334
335
  end
335
336
 
336
337
  it "should find existing package" do
@@ -380,6 +381,7 @@ describe "Parameter type mapping /" do
380
381
 
381
382
  describe "Function with output parameters" do
382
383
  before(:all) do
384
+ plsql.connect! CONNECTION_PARAMS
383
385
  plsql.execute <<-SQL
384
386
  CREATE OR REPLACE FUNCTION test_copy_function
385
387
  ( p_from VARCHAR2, p_to OUT VARCHAR2, p_to_double OUT VARCHAR2 )
@@ -395,6 +397,7 @@ describe "Parameter type mapping /" do
395
397
 
396
398
  after(:all) do
397
399
  plsql.execute "DROP FUNCTION test_copy_function"
400
+ plsql.logoff
398
401
  end
399
402
 
400
403
  it "should return array with return value and hash of output parameters" do
@@ -414,6 +417,7 @@ describe "Parameter type mapping /" do
414
417
 
415
418
  describe "Function or procedure without parameters" do
416
419
  before(:all) do
420
+ plsql.connect! CONNECTION_PARAMS
417
421
  plsql.execute <<-SQL
418
422
  CREATE OR REPLACE FUNCTION test_no_params
419
423
  RETURN VARCHAR2
@@ -434,6 +438,7 @@ describe "Parameter type mapping /" do
434
438
  after(:all) do
435
439
  plsql.execute "DROP FUNCTION test_no_params"
436
440
  plsql.execute "DROP PROCEDURE test_proc_no_params"
441
+ plsql.logoff
437
442
  end
438
443
 
439
444
  it "should find function" do
@@ -455,8 +460,8 @@ describe "Parameter type mapping /" do
455
460
  end
456
461
 
457
462
  describe "Function with CLOB parameter and return value" do
458
-
459
463
  before(:all) do
464
+ plsql.connect! CONNECTION_PARAMS
460
465
  plsql.execute <<-SQL
461
466
  CREATE OR REPLACE FUNCTION test_clob
462
467
  ( p_clob CLOB )
@@ -466,10 +471,35 @@ describe "Parameter type mapping /" do
466
471
  RETURN p_clob;
467
472
  END test_clob;
468
473
  SQL
474
+ plsql.execute "CREATE TABLE test_clob_table (clob_col CLOB)"
475
+ plsql.execute <<-SQL
476
+ CREATE OR REPLACE FUNCTION test_clob_insert
477
+ ( p_clob CLOB )
478
+ RETURN CLOB
479
+ IS
480
+ CURSOR clob_cur IS
481
+ SELECT clob_col
482
+ FROM test_clob_table;
483
+
484
+ v_dummy CLOB;
485
+ BEGIN
486
+ DELETE FROM test_clob_table;
487
+ INSERT INTO test_clob_table (clob_col) VALUES (p_clob);
488
+
489
+ OPEN clob_cur;
490
+ FETCH clob_cur INTO v_dummy;
491
+ CLOSE clob_cur;
492
+
493
+ RETURN v_dummy;
494
+ END test_clob_insert;
495
+ SQL
469
496
  end
470
497
 
471
498
  after(:all) do
472
499
  plsql.execute "DROP FUNCTION test_clob"
500
+ plsql.execute "DROP FUNCTION test_clob_insert"
501
+ plsql.execute "DROP TABLE test_clob_table"
502
+ plsql.logoff
473
503
  end
474
504
 
475
505
  it "should find existing procedure" do
@@ -487,6 +517,11 @@ describe "Parameter type mapping /" do
487
517
  text = ''
488
518
  plsql.test_clob(text).should be_nil
489
519
  end
520
+
521
+ it "should execute function which inserts the CLOB parameter into a table with empty string and return nil" do
522
+ text = ''
523
+ plsql.test_clob_insert(text).should be_nil
524
+ end
490
525
 
491
526
  else
492
527
 
@@ -501,11 +536,15 @@ describe "Parameter type mapping /" do
501
536
  plsql.test_clob(nil).should be_nil
502
537
  end
503
538
 
539
+ it "should execute function which inserts the CLOB parameter into a table with nil and return nil" do
540
+ plsql.test_clob_insert(nil).should be_nil
541
+ end
542
+
504
543
  end
505
544
 
506
545
  describe "Procedrue with CLOB parameter and return value" do
507
-
508
546
  before(:all) do
547
+ plsql.connect! CONNECTION_PARAMS
509
548
  plsql.execute <<-SQL
510
549
  CREATE OR REPLACE PROCEDURE test_clob_proc
511
550
  ( p_clob CLOB,
@@ -519,6 +558,7 @@ describe "Parameter type mapping /" do
519
558
 
520
559
  after(:all) do
521
560
  plsql.execute "DROP PROCEDURE test_clob_proc"
561
+ plsql.logoff
522
562
  end
523
563
 
524
564
  it "should find existing procedure" do
@@ -532,8 +572,8 @@ describe "Parameter type mapping /" do
532
572
  end
533
573
 
534
574
  describe "Procedrue with BLOB parameter and return value" do
535
-
536
575
  before(:all) do
576
+ plsql.connect! CONNECTION_PARAMS
537
577
  plsql.execute <<-SQL
538
578
  CREATE OR REPLACE PROCEDURE test_blob_proc
539
579
  ( p_blob BLOB,
@@ -547,6 +587,7 @@ describe "Parameter type mapping /" do
547
587
 
548
588
  after(:all) do
549
589
  plsql.execute "DROP PROCEDURE test_blob_proc"
590
+ plsql.logoff
550
591
  end
551
592
 
552
593
  it "should find existing procedure" do
@@ -560,8 +601,8 @@ describe "Parameter type mapping /" do
560
601
  end
561
602
 
562
603
  describe "Function with record parameter" do
563
-
564
604
  before(:all) do
605
+ plsql.connect! CONNECTION_PARAMS
565
606
  plsql.execute "DROP TABLE test_employees" rescue nil
566
607
  plsql.execute <<-SQL
567
608
  CREATE TABLE test_employees (
@@ -587,8 +628,14 @@ describe "Parameter type mapping /" do
587
628
  last_name VARCHAR2(50),
588
629
  hire_date DATE
589
630
  );
590
- FUNCTION test_full_name (p_employee t_employee)
631
+
632
+ TYPE table_of_records IS TABLE OF t_employee;
633
+
634
+ FUNCTION test_full_name(p_employee t_employee)
591
635
  RETURN VARCHAR2;
636
+
637
+ FUNCTION test_empty_records
638
+ RETURN table_of_records;
592
639
  END;
593
640
  SQL
594
641
  plsql.execute <<-SQL
@@ -599,6 +646,26 @@ describe "Parameter type mapping /" do
599
646
  BEGIN
600
647
  RETURN p_employee.first_name || ' ' || p_employee.last_name;
601
648
  END;
649
+
650
+ FUNCTION test_empty_records
651
+ RETURN table_of_records
652
+ IS
653
+ CURSOR employees_cur
654
+ IS
655
+ SELECT
656
+ null employee_id,
657
+ null first_name,
658
+ null last_name,
659
+ null hire_date
660
+ FROM dual
661
+ WHERE 1 = 2;
662
+ employees_tab table_of_records;
663
+ BEGIN
664
+ OPEN employees_cur;
665
+ FETCH employees_cur BULK COLLECT INTO employees_tab;
666
+ CLOSE employees_cur;
667
+ RETURN employees_tab;
668
+ END;
602
669
  END;
603
670
  SQL
604
671
  plsql.execute <<-SQL
@@ -641,6 +708,7 @@ describe "Parameter type mapping /" do
641
708
  plsql.execute "DROP FUNCTION test_employee_record"
642
709
  plsql.execute "DROP FUNCTION test_employee_record2"
643
710
  plsql.execute "DROP TABLE test_employees"
711
+ plsql.logoff
644
712
  end
645
713
 
646
714
  it "should find existing function" do
@@ -664,6 +732,10 @@ describe "Parameter type mapping /" do
664
732
  plsql.test_full_name(@p_employee.merge :xxx => 'xxx').should == 'Second Last'
665
733
  end.should raise_error(ArgumentError)
666
734
  end
735
+
736
+ it "should return empty table of records" do
737
+ plsql.test_record.test_empty_records().should == []
738
+ end
667
739
 
668
740
  it "should return record return value" do
669
741
  plsql.test_employee_record(@p_employee).should == @p_employee
@@ -680,8 +752,8 @@ describe "Parameter type mapping /" do
680
752
  end
681
753
 
682
754
  describe "Function with boolean parameters" do
683
-
684
755
  before(:all) do
756
+ plsql.connect! CONNECTION_PARAMS
685
757
  plsql.execute <<-SQL
686
758
  CREATE OR REPLACE FUNCTION test_boolean
687
759
  ( p_boolean BOOLEAN )
@@ -704,6 +776,7 @@ describe "Parameter type mapping /" do
704
776
  after(:all) do
705
777
  plsql.execute "DROP FUNCTION test_boolean"
706
778
  plsql.execute "DROP PROCEDURE test_boolean2"
779
+ plsql.logoff
707
780
  end
708
781
 
709
782
  it "should accept true value and return true value" do
@@ -733,8 +806,8 @@ describe "Parameter type mapping /" do
733
806
  end
734
807
 
735
808
  describe "Function with object type parameter" do
736
-
737
809
  before(:all) do
810
+ plsql.connect! CONNECTION_PARAMS
738
811
  plsql.execute "DROP TYPE t_employee" rescue nil
739
812
  plsql.execute "DROP TYPE t_phones" rescue nil
740
813
  plsql.execute <<-SQL
@@ -806,6 +879,7 @@ describe "Parameter type mapping /" do
806
879
  plsql.execute "DROP TYPE t_address"
807
880
  plsql.execute "DROP TYPE t_phones"
808
881
  plsql.execute "DROP TYPE t_phone"
882
+ plsql.logoff
809
883
  end
810
884
 
811
885
  it "should find existing function" do
@@ -834,12 +908,16 @@ describe "Parameter type mapping /" do
834
908
  plsql.test_employee_object2(@p_employee, nil).should == [@p_employee, {:x_employee => @p_employee}]
835
909
  end
836
910
 
911
+ it "should accept NULL as input parameter" do
912
+ plsql.test_employee_object(nil).should == nil
913
+ end
914
+
837
915
  end
838
916
 
839
917
 
840
918
  describe "Function with table parameter" do
841
-
842
919
  before(:all) do
920
+ plsql.connect! CONNECTION_PARAMS
843
921
  # Array of numbers
844
922
  plsql.execute <<-SQL
845
923
  CREATE OR REPLACE TYPE t_numbers AS TABLE OF NUMBER(15)
@@ -862,7 +940,7 @@ describe "Parameter type mapping /" do
862
940
  END IF;
863
941
  END;
864
942
  SQL
865
-
943
+
866
944
  plsql.execute <<-SQL
867
945
  CREATE OR REPLACE FUNCTION test_increment(p_numbers IN t_numbers, p_increment_by IN NUMBER DEFAULT 1)
868
946
  RETURN t_numbers
@@ -905,6 +983,8 @@ describe "Parameter type mapping /" do
905
983
  TYPE t_numbers IS TABLE OF NUMBER(15);
906
984
  FUNCTION test_sum (p_numbers IN t_numbers)
907
985
  RETURN NUMBER;
986
+ FUNCTION test_function_failure (p_numbers IN t_numbers, p_force_failure IN VARCHAR2 DEFAULT 'N')
987
+ RETURN NUMBER;
908
988
  FUNCTION test_numbers (p_numbers IN t_numbers, x_numbers OUT t_numbers)
909
989
  RETURN t_numbers;
910
990
  TYPE t_employee IS RECORD(
@@ -929,6 +1009,18 @@ describe "Parameter type mapping /" do
929
1009
  TYPE t_employees2 IS TABLE OF t_employee2;
930
1010
  FUNCTION test_employees2 (p_employees IN OUT t_employees2)
931
1011
  RETURN t_employees2;
1012
+
1013
+ TYPE t_nstring IS RECORD(
1014
+ ch_10bytes CHAR(10 BYTE),
1015
+ ch_10chars CHAR(10 CHAR),
1016
+ nch_10chars NCHAR(10 CHAR),
1017
+ str_10bytes VARCHAR2(10 BYTE),
1018
+ str_10chars VARCHAR2(10 CHAR),
1019
+ nstr_10chars NVARCHAR2(10)
1020
+ );
1021
+ TYPE t_nstrings IS TABLE OF t_nstring;
1022
+ FUNCTION test_nstring (p_strings IN t_nstrings, p_out OUT t_nstrings)
1023
+ return NVARCHAR2;
932
1024
  END;
933
1025
  SQL
934
1026
  plsql.execute <<-SQL
@@ -949,6 +1041,15 @@ describe "Parameter type mapping /" do
949
1041
  RETURN NULL;
950
1042
  END IF;
951
1043
  END;
1044
+ FUNCTION test_function_failure (p_numbers IN t_numbers, p_force_failure IN VARCHAR2 DEFAULT 'N')
1045
+ RETURN NUMBER
1046
+ IS
1047
+ BEGIN
1048
+ IF p_force_failure = 'Y' THEN
1049
+ raise_application_error(-20000, 'Simulate business error to test clearing of temp table.');
1050
+ END IF;
1051
+ RETURN p_numbers.COUNT;
1052
+ END;
952
1053
  FUNCTION test_numbers (p_numbers IN t_numbers, x_numbers OUT t_numbers)
953
1054
  RETURN t_numbers
954
1055
  IS
@@ -974,6 +1075,23 @@ describe "Parameter type mapping /" do
974
1075
  BEGIN
975
1076
  RETURN p_employees;
976
1077
  END;
1078
+ FUNCTION test_nstring (p_strings IN t_nstrings, p_out OUT t_nstrings)
1079
+ return NVARCHAR2
1080
+ IS
1081
+ tmp1 NVARCHAR2(2000);
1082
+ x pls_integer;
1083
+ BEGIN
1084
+ p_out := p_strings;
1085
+ IF p_strings.count=0 THEN
1086
+ RETURN N'';
1087
+ END IF;
1088
+ x := p_strings.first;
1089
+ WHILE x IS NOT NULL LOOP
1090
+ tmp1 := tmp1 || rtrim(p_strings(x).nch_10chars) || p_strings(x).nstr_10chars || ',';
1091
+ x := p_strings.next(x);
1092
+ END LOOP;
1093
+ RETURN tmp1;
1094
+ END;
977
1095
  END;
978
1096
  SQL
979
1097
  @employees = (1..10).map do |i|
@@ -984,6 +1102,16 @@ describe "Parameter type mapping /" do
984
1102
  :hire_date => Time.local(2000,01,i),
985
1103
  }
986
1104
  end
1105
+ @nstrings = (1..5).map do |i|
1106
+ {
1107
+ :ch_10bytes => "Ch #{i}B ",
1108
+ :ch_10chars => "Ch #{i}C ",
1109
+ :nch_10chars => "NCh #{i} ",
1110
+ :str_10bytes => "Str #{i}C",
1111
+ :str_10chars => "Str #{i}B",
1112
+ :nstr_10chars => "NStr #{i}",
1113
+ }
1114
+ end
987
1115
 
988
1116
  # Array of objects
989
1117
  plsql.execute <<-SQL
@@ -1017,6 +1145,7 @@ describe "Parameter type mapping /" do
1017
1145
  plsql.execute "DROP TYPE t_phones"
1018
1146
  plsql.execute "DROP TYPE t_phone"
1019
1147
  plsql.connection.drop_session_ruby_temporary_tables
1148
+ plsql.logoff
1020
1149
  end
1021
1150
 
1022
1151
  it "should find existing function" do
@@ -1026,7 +1155,7 @@ describe "Parameter type mapping /" do
1026
1155
  it "should execute function with number array parameter" do
1027
1156
  plsql.test_sum([1,2,3,4]).should == 10
1028
1157
  end
1029
-
1158
+
1030
1159
  it "should return number array return value" do
1031
1160
  plsql.test_increment([1,2,3,4], 1).should == [2,3,4,5]
1032
1161
  end
@@ -1040,6 +1169,15 @@ describe "Parameter type mapping /" do
1040
1169
  plsql.test_collections.test_sum([1,2,3,4]).should == 10
1041
1170
  end
1042
1171
 
1172
+ it "should clear temporary tables after executing function with table of numbers type even if an error occurs in the package" do
1173
+ # this should work fine
1174
+ plsql.test_collections.test_function_failure([1,2,3,4], 'N').should == 4
1175
+ # we will force a package error here to see if things get cleaned up before the next call
1176
+ lambda { plsql.test_collections.test_function_failure([1,2,3,4], 'Y') }.should raise_error(/Simulate business error to test clearing of temp table/)
1177
+ # after the error in the first call temporary tables should be cleared
1178
+ plsql.test_collections.test_function_failure([5,6,7], 'N').should == 3
1179
+ end
1180
+
1043
1181
  it "should return table of numbers type (defined inside package)" do
1044
1182
  plsql.test_collections.test_numbers([1,2,3,4]).should == [[1,2,3,4], {:x_numbers => [1,2,3,4]}]
1045
1183
  end
@@ -1064,6 +1202,10 @@ describe "Parameter type mapping /" do
1064
1202
  plsql.test_collections.test_employees(@employees).should == [@employees, {:p_employees => @employees}]
1065
1203
  end
1066
1204
 
1205
+ it "should execute function with table of records type (defined inside package and includes NVARCHAR columns) parameter" do
1206
+ plsql.test_collections.test_nstring(@nstrings).should == [(1..5).map{|i| "NCh #{i}NStr #{i},"}.join, {:p_out => @nstrings}]
1207
+ end
1208
+
1067
1209
  it "should execute function with object array and return object array output parameter" do
1068
1210
  phones = [{:type => 'mobile', :phone_number => '123456'}, {:type => 'home', :phone_number => '654321'}]
1069
1211
  plsql.test_copy_objects(phones).should == [phones, {:x_phones => phones}]
@@ -1089,8 +1231,8 @@ describe "Parameter type mapping /" do
1089
1231
  end
1090
1232
 
1091
1233
  describe "Function with table indexed by bynary integer parameter" do
1092
-
1093
1234
  before(:all) do
1235
+ plsql.connect! CONNECTION_PARAMS
1094
1236
  plsql.execute <<-SQL
1095
1237
  CREATE TABLE test_employees (
1096
1238
  employee_id NUMBER(15),
@@ -1106,6 +1248,8 @@ describe "Parameter type mapping /" do
1106
1248
  INDEX BY BINARY_INTEGER;
1107
1249
  FUNCTION test_sum (p_numbers IN t_numbers)
1108
1250
  RETURN NUMBER;
1251
+ FUNCTION test_function_failure (p_numbers IN t_numbers, p_force_failure IN VARCHAR2 DEFAULT 'N')
1252
+ RETURN NUMBER;
1109
1253
  FUNCTION test_numbers (p_numbers IN t_numbers, x_numbers OUT t_numbers)
1110
1254
  RETURN t_numbers;
1111
1255
  TYPE t_employee IS RECORD(
@@ -1142,6 +1286,27 @@ describe "Parameter type mapping /" do
1142
1286
  RETURN NULL;
1143
1287
  END IF;
1144
1288
  END;
1289
+ FUNCTION test_function_failure (p_numbers IN t_numbers, p_force_failure IN VARCHAR2 DEFAULT 'N')
1290
+ RETURN NUMBER
1291
+ IS
1292
+ l_sum NUMBER(15) := 0;
1293
+ i BINARY_INTEGER;
1294
+ BEGIN
1295
+ IF p_force_failure = 'Y' THEN
1296
+ raise_application_error(-20000, 'Simulate business error to test clearing of temp table.');
1297
+ END IF;
1298
+ IF p_numbers.COUNT > 0 THEN
1299
+ i := p_numbers.FIRST;
1300
+ LOOP
1301
+ EXIT WHEN i IS NULL;
1302
+ l_sum := l_sum + p_numbers(i);
1303
+ i := p_numbers.NEXT(i);
1304
+ END LOOP;
1305
+ RETURN l_sum;
1306
+ ELSE
1307
+ RETURN NULL;
1308
+ END IF;
1309
+ END;
1145
1310
  FUNCTION test_numbers (p_numbers IN t_numbers, x_numbers OUT t_numbers)
1146
1311
  RETURN t_numbers
1147
1312
  IS
@@ -1169,21 +1334,32 @@ describe "Parameter type mapping /" do
1169
1334
  SQL
1170
1335
  # test with negative PL/SQL table indexes
1171
1336
  @numbers = Hash[*(1..4).map{|i|[-i,i]}.flatten]
1337
+ @numbers2 = Hash[*(5..7).map{|i|[-i,i]}.flatten]
1172
1338
  # test with reversed PL/SQL table indexes
1173
1339
  @employees = Hash[*(1..10).map do |i|
1174
- [11-i, {
1175
- :employee_id => i,
1176
- :first_name => "First #{i}",
1177
- :last_name => "Last #{i}",
1178
- :hire_date => Time.local(2000,01,i)
1179
- }]
1180
- end.flatten]
1340
+ [11-i, {
1341
+ :employee_id => i,
1342
+ :first_name => "First #{i}",
1343
+ :last_name => "Last #{i}",
1344
+ :hire_date => Time.local(2000,01,i)
1345
+ }]
1346
+ end.flatten]
1181
1347
  end
1182
1348
 
1183
1349
  after(:all) do
1184
1350
  plsql.execute "DROP PACKAGE test_collections"
1185
1351
  plsql.execute "DROP TABLE test_employees"
1186
1352
  plsql.connection.drop_session_ruby_temporary_tables
1353
+ plsql.logoff
1354
+ end
1355
+
1356
+ it "should clear temporary tables after executing function with index-by table of numbers type even if an error occurs in the package" do
1357
+ # this should work fine
1358
+ plsql.test_collections.test_function_failure(@numbers, 'N').should == 10
1359
+ # we will force a package error here to see if things get cleaned up before the next call
1360
+ lambda { plsql.test_collections.test_function_failure(@numbers, 'Y') }.should raise_error(/Simulate business error to test clearing of temp table/)
1361
+ # after the error in the first call temporary tables should be cleared
1362
+ plsql.test_collections.test_function_failure(@numbers2, 'N').should == 18
1187
1363
  end
1188
1364
 
1189
1365
  it "should execute function with index-by table of numbers type (defined inside package) parameter" do
@@ -1244,8 +1420,8 @@ describe "Parameter type mapping /" do
1244
1420
 
1245
1421
 
1246
1422
  describe "Function with VARRAY parameter" do
1247
-
1248
1423
  before(:all) do
1424
+ plsql.connect! CONNECTION_PARAMS
1249
1425
  # Array of numbers
1250
1426
  plsql.execute <<-SQL
1251
1427
  CREATE OR REPLACE TYPE t_numbers_array AS VARRAY(100) OF NUMBER(15)
@@ -1266,7 +1442,7 @@ describe "Parameter type mapping /" do
1266
1442
  END IF;
1267
1443
  END;
1268
1444
  SQL
1269
-
1445
+
1270
1446
  plsql.execute <<-SQL
1271
1447
  CREATE OR REPLACE FUNCTION test_increment(p_numbers IN t_numbers_array, p_increment_by IN NUMBER DEFAULT 1)
1272
1448
  RETURN t_numbers_array
@@ -1280,7 +1456,7 @@ describe "Parameter type mapping /" do
1280
1456
  RETURN l_numbers;
1281
1457
  END;
1282
1458
  SQL
1283
-
1459
+
1284
1460
  # Array of strings
1285
1461
  plsql.execute <<-SQL
1286
1462
  CREATE OR REPLACE TYPE t_strings_array AS VARRAY(100) OF VARCHAR2(4000)
@@ -1330,6 +1506,7 @@ describe "Parameter type mapping /" do
1330
1506
  plsql.execute "DROP TYPE t_strings_array"
1331
1507
  plsql.execute "DROP TYPE t_phones_array"
1332
1508
  plsql.execute "DROP TYPE t_phone"
1509
+ plsql.logoff
1333
1510
  end
1334
1511
 
1335
1512
  it "should find existing function" do
@@ -1361,9 +1538,148 @@ describe "Parameter type mapping /" do
1361
1538
 
1362
1539
  end
1363
1540
 
1364
- describe "Function with cursor return value or parameter" do
1541
+ describe "Function in package with VARRAY parameter" do
1542
+ before(:all) do
1543
+ plsql.connect! CONNECTION_PARAMS
1544
+ plsql.execute <<-SQL
1545
+ CREATE OR REPLACE TYPE t_phone AS OBJECT (
1546
+ type VARCHAR2(10),
1547
+ phone_number VARCHAR2(50)
1548
+ )
1549
+ SQL
1550
+
1551
+ plsql.execute <<-SQL
1552
+ CREATE OR REPLACE PACKAGE test_collections IS
1553
+ TYPE t_numbers_array IS VARRAY(100) OF NUMBER(15);
1554
+ TYPE t_strings_array IS VARRAY(100) OF VARCHAR2(4000);
1555
+ TYPE t_phones_array IS ARRAY(100) OF T_PHONE;
1556
+ FUNCTION test_sum (p_numbers IN t_numbers_array)
1557
+ RETURN NUMBER;
1558
+ FUNCTION test_function_failure (p_numbers IN t_numbers_array, p_force_failure IN VARCHAR2 DEFAULT 'N')
1559
+ RETURN NUMBER;
1560
+ FUNCTION test_increment(p_numbers IN t_numbers_array, p_increment_by IN NUMBER DEFAULT 1)
1561
+ RETURN t_numbers_array;
1562
+ FUNCTION test_copy_strings(p_strings IN t_strings_array, x_strings OUT t_strings_array)
1563
+ RETURN t_strings_array;
1564
+ FUNCTION test_copy_objects(p_phones IN t_phones_array, x_phones OUT t_phones_array)
1565
+ RETURN t_phones_array;
1566
+ END;
1567
+ SQL
1568
+
1569
+ plsql.execute <<-SQL
1570
+ CREATE OR REPLACE PACKAGE BODY test_collections IS
1571
+ FUNCTION test_sum (p_numbers IN t_numbers_array)
1572
+ RETURN NUMBER
1573
+ IS
1574
+ l_sum NUMBER(15) := 0;
1575
+ BEGIN
1576
+ IF p_numbers.COUNT > 0 THEN
1577
+ FOR i IN p_numbers.FIRST..p_numbers.LAST LOOP
1578
+ l_sum := l_sum + p_numbers(i);
1579
+ END LOOP;
1580
+ RETURN l_sum;
1581
+ ELSE
1582
+ RETURN NULL;
1583
+ END IF;
1584
+ END;
1585
+
1586
+ FUNCTION test_function_failure (p_numbers IN t_numbers_array, p_force_failure IN VARCHAR2 DEFAULT 'N')
1587
+ RETURN NUMBER
1588
+ IS
1589
+ l_sum NUMBER(15) := 0;
1590
+ BEGIN
1591
+ IF p_force_failure = 'Y' THEN
1592
+ raise_application_error(-20000, 'Simulate business error to test clearing of temp table.');
1593
+ END IF;
1594
+ IF p_numbers.COUNT > 0 THEN
1595
+ FOR i IN p_numbers.FIRST..p_numbers.LAST LOOP
1596
+ l_sum := l_sum + p_numbers(i);
1597
+ END LOOP;
1598
+ RETURN l_sum;
1599
+ ELSE
1600
+ RETURN NULL;
1601
+ END IF;
1602
+ END;
1365
1603
 
1604
+ FUNCTION test_increment(p_numbers IN t_numbers_array, p_increment_by IN NUMBER DEFAULT 1)
1605
+ RETURN t_numbers_array
1606
+ IS
1607
+ l_numbers t_numbers_array := t_numbers_array();
1608
+ BEGIN
1609
+ FOR i IN p_numbers.FIRST..p_numbers.LAST LOOP
1610
+ l_numbers.EXTEND;
1611
+ l_numbers(i) := p_numbers(i) + p_increment_by;
1612
+ END LOOP;
1613
+ RETURN l_numbers;
1614
+ END;
1615
+
1616
+ FUNCTION test_copy_strings(p_strings IN t_strings_array, x_strings OUT t_strings_array)
1617
+ RETURN t_strings_array
1618
+ IS
1619
+ BEGIN
1620
+ x_strings := t_strings_array();
1621
+ FOR i IN p_strings.FIRST..p_strings.LAST LOOP
1622
+ x_strings.EXTEND;
1623
+ x_strings(i) := p_strings(i);
1624
+ END LOOP;
1625
+ RETURN x_strings;
1626
+ END;
1627
+
1628
+ FUNCTION test_copy_objects(p_phones IN t_phones_array, x_phones OUT t_phones_array)
1629
+ RETURN t_phones_array
1630
+ IS
1631
+ BEGIN
1632
+ x_phones := p_phones;
1633
+ RETURN x_phones;
1634
+ END;
1635
+ END;
1636
+ SQL
1637
+ end
1638
+
1639
+ after(:all) do
1640
+ plsql.execute "DROP PACKAGE test_collections"
1641
+ plsql.execute "DROP TYPE t_phone" rescue nil
1642
+ plsql.logoff
1643
+ end
1644
+
1645
+ it "should execute function with number array parameter" do
1646
+ plsql.test_collections.test_sum([1,2,3,4]).should == 10
1647
+ end
1648
+
1649
+ it "should clear temporary tables after executing function with varray of numbers type even if an error occurs in the package" do
1650
+ # this should work fine
1651
+ plsql.test_collections.test_function_failure([1,2,3,4], 'N').should == 10
1652
+ # we will force a package error here to see if things get cleaned up before the next call
1653
+ lambda { plsql.test_collections.test_function_failure([5,6,7], 'Y') }.should raise_error(/Simulate business error to test clearing of temp table/)
1654
+ # after the error in the first call temporary tables should be cleared
1655
+ plsql.test_collections.test_function_failure([3,4,5,6], 'N').should == 18
1656
+ end
1657
+
1658
+ it "should return number array return value" do
1659
+ plsql.test_collections.test_increment([1,2,3,4], 1).should == [2,3,4,5]
1660
+ end
1661
+
1662
+ it "should execute function with string array and return string array output parameter" do
1663
+ strings = ['1','2','3','4']
1664
+ plsql.test_collections.test_copy_strings(strings).should == [strings, {:x_strings => strings}]
1665
+ end
1666
+
1667
+ it "should execute function with object array and return object array output parameter" do
1668
+ phones = [{:type => 'mobile', :phone_number => '123456'}, {:type => 'home', :phone_number => '654321'}]
1669
+ plsql.test_collections.test_copy_objects(phones).should == [phones, {:x_phones => phones}]
1670
+ end
1671
+
1672
+ # This test fails without wcmatthysen's "Procedure-call Fix." pull request.
1673
+ # it "should execute function with empty object array" do
1674
+ # phones = []
1675
+ # plsql.test_collections.test_copy_objects(phones).should == [phones, {:x_phones => phones}]
1676
+ # end
1677
+
1678
+ end
1679
+
1680
+ describe "Function with cursor return value or parameter" do
1366
1681
  before(:all) do
1682
+ plsql.connect! CONNECTION_PARAMS
1367
1683
  plsql.execute "DROP TABLE test_employees" rescue nil
1368
1684
  plsql.execute <<-SQL
1369
1685
  CREATE TABLE test_employees (
@@ -1431,6 +1747,7 @@ describe "Parameter type mapping /" do
1431
1747
  plsql.execute "DROP PROCEDURE test_insert_employee"
1432
1748
  plsql.execute "DROP FUNCTION test_cursor_fetch"
1433
1749
  plsql.execute "DROP TABLE test_employees"
1750
+ plsql.logoff
1434
1751
  end
1435
1752
 
1436
1753
  it "should find existing function" do
@@ -1497,6 +1814,7 @@ describe "Parameter type mapping /" do
1497
1814
 
1498
1815
  it "should execute function with cursor parameter and return record" do
1499
1816
  pending "not possible from JDBC" if defined?(JRUBY_VERSION)
1817
+ pending "fails with core dump with ruby-oci8 2.1.0" if OCI8::VERSION >= "2.1.0"
1500
1818
  plsql.test_cursor do |cursor|
1501
1819
  plsql.test_cursor_fetch(cursor).should == @employees[0]
1502
1820
  end
@@ -1505,8 +1823,8 @@ describe "Parameter type mapping /" do
1505
1823
  end
1506
1824
 
1507
1825
  describe "Function with typed ref cursor return value" do
1508
-
1509
1826
  before(:all) do
1827
+ plsql.connect! CONNECTION_PARAMS
1510
1828
  plsql.execute "DROP TABLE typed_ref_cursor_table" rescue nil
1511
1829
 
1512
1830
  plsql.execute <<-SQL
@@ -1544,6 +1862,7 @@ describe "Parameter type mapping /" do
1544
1862
  after(:all) do
1545
1863
  plsql.execute "DROP PACKAGE typed_ref_cursor_test"
1546
1864
  plsql.execute "DROP TABLE typed_ref_cursor_table"
1865
+ plsql.logoff
1547
1866
  end
1548
1867
 
1549
1868
  it "should return cursor and fetch first row" do
@@ -1569,7 +1888,6 @@ describe "Parameter type mapping /" do
1569
1888
  end
1570
1889
 
1571
1890
  describe "Synonyms /" do
1572
-
1573
1891
  before(:all) do
1574
1892
  plsql.connect! CONNECTION_PARAMS
1575
1893
  end