ruby-plsql 0.1.5 → 0.1.6

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.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.1.6 2008-06-16
2
+
3
+ * Improvements
4
+ * If PL/SQL functions with output parameters are called then the result will be array with the function return value as a first element
5
+ and a hash with output parameters values as a second element.
6
+
1
7
  == 0.1.5 2008-06-13
2
8
 
3
9
  * Bug fixes
@@ -155,8 +155,14 @@ module PLSQL
155
155
 
156
156
  cursor.exec
157
157
 
158
- # if function
159
- if @return[overload]
158
+ # if function with output parameters
159
+ if @return[overload] && @out_list[overload].size > 0
160
+ result = [ora_value_to_ruby_value(cursor[':return']), {}]
161
+ @out_list[overload].each do |k|
162
+ result[1][k] = ora_value_to_ruby_value(cursor[":#{k}"])
163
+ end
164
+ # if function without output parameters
165
+ elsif @return[overload]
160
166
  result = ora_value_to_ruby_value(cursor[':return'])
161
167
  # if procedure with output parameters
162
168
  elsif @out_list[overload].size > 0
@@ -2,7 +2,7 @@ module RubyPlsql #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 5
5
+ TINY = 6
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  require "rubygems"
4
4
  require "activerecord"
5
5
 
6
- describe "Procedure with string parameters" do
6
+ describe "Function with string parameters" do
7
7
 
8
8
  before(:all) do
9
9
  plsql.connection = conn = OCI8.new("hr","hr","xe")
@@ -56,7 +56,7 @@ describe "Procedure with string parameters" do
56
56
 
57
57
  end
58
58
 
59
- describe "Procedure with numeric parameters" do
59
+ describe "Function with numeric parameters" do
60
60
 
61
61
  before(:all) do
62
62
  plsql.connection = conn = OCI8.new("hr","hr","xe")
@@ -97,7 +97,7 @@ describe "Procedure with numeric parameters" do
97
97
 
98
98
  end
99
99
 
100
- describe "Procedure with date parameters" do
100
+ describe "Function with date parameters" do
101
101
 
102
102
  before(:all) do
103
103
  plsql.connection = conn = OCI8.new("hr","hr","xe")
@@ -142,7 +142,7 @@ describe "Procedure with date parameters" do
142
142
 
143
143
  end
144
144
 
145
- describe "Procedure with timestamp parameters" do
145
+ describe "Function with timestamp parameters" do
146
146
 
147
147
  before(:all) do
148
148
  plsql.connection = conn = OCI8.new("hr","hr","xe")
@@ -186,11 +186,11 @@ describe "Procedure with output parameters" do
186
186
  plsql.logoff
187
187
  end
188
188
 
189
- it "should return array with output parameters" do
189
+ it "should return hash with output parameters" do
190
190
  plsql.test_copy("abc", nil, nil).should == { :p_to => "abc", :p_to_double => "abcabc" }
191
191
  end
192
192
 
193
- it "should return array with output parameters when called with named parameters" do
193
+ it "should return hash with output parameters when called with named parameters" do
194
194
  plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil).should == { :p_to => "abc", :p_to_double => "abcabc" }
195
195
  end
196
196
 
@@ -292,3 +292,64 @@ describe "Package with procedures with same name but different argument lists" d
292
292
  end
293
293
 
294
294
  end
295
+
296
+ describe "Function with output parameters" do
297
+ before(:all) do
298
+ plsql.connection = conn = OCI8.new("hr","hr","xe")
299
+ plsql.connection.exec <<-EOS
300
+ CREATE OR REPLACE FUNCTION test_copy_function
301
+ ( p_from VARCHAR2, p_to OUT VARCHAR2, p_to_double OUT VARCHAR2 )
302
+ RETURN NUMBER
303
+ IS
304
+ BEGIN
305
+ p_to := p_from;
306
+ p_to_double := p_from || p_from;
307
+ RETURN LENGTH(p_from);
308
+ END test_copy_function;
309
+ EOS
310
+ end
311
+
312
+ after(:all) do
313
+ plsql.logoff
314
+ end
315
+
316
+ it "should return array with return value and hash of output parameters" do
317
+ plsql.test_copy_function("abc", nil, nil).should == [3, { :p_to => "abc", :p_to_double => "abcabc" }]
318
+ end
319
+
320
+ it "should return array with return value and hash of output parameters when called with named parameters" do
321
+ plsql.test_copy_function(:p_from => "abc", :p_to => nil, :p_to_double => nil).should ==
322
+ [3, { :p_to => "abc", :p_to_double => "abcabc" }]
323
+ end
324
+
325
+ it "should substitute output parameters with nil if they are not specified" do
326
+ plsql.test_copy_function("abc").should == [3, { :p_to => "abc", :p_to_double => "abcabc" }]
327
+ end
328
+
329
+ it "should substitute all parementers with nil if none are specified" do
330
+ plsql.test_copy_function.should == [nil, { :p_to => nil, :p_to_double => nil }]
331
+ end
332
+
333
+ end
334
+
335
+ describe "Function without parameters" do
336
+ before(:all) do
337
+ plsql.connection = conn = OCI8.new("hr","hr","xe")
338
+ plsql.connection.exec <<-EOS
339
+ CREATE OR REPLACE FUNCTION test_no_params
340
+ RETURN VARCHAR2
341
+ IS
342
+ BEGIN
343
+ RETURN 'dummy';
344
+ END test_no_params;
345
+ EOS
346
+ end
347
+
348
+ after(:all) do
349
+ plsql.logoff
350
+ end
351
+
352
+ it "should return value" do
353
+ plsql.test_no_params.should == "dummy"
354
+ end
355
+ end
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>Ruby API for PL/SQL</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/ruby-plsql"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/ruby-plsql" class="numbers">0.1.5</a>
36
+ <a href="http://rubyforge.org/projects/ruby-plsql" class="numbers">0.1.6</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;ruby-plsql&#8217;</h1>
39
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-plsql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raimonds Simanovskis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-15 00:00:00 +03:00
12
+ date: 2008-06-26 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15