ruby-plsql 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +19 -0
- data/License.txt +1 -1
- data/README.rdoc +9 -4
- data/VERSION +1 -1
- data/lib/plsql/connection.rb +24 -9
- data/lib/plsql/helpers.rb +9 -0
- data/lib/plsql/jdbc_connection.rb +38 -9
- data/lib/plsql/oci8_patches.rb +25 -0
- data/lib/plsql/oci_connection.rb +46 -12
- data/lib/plsql/package.rb +25 -12
- data/lib/plsql/procedure.rb +23 -29
- data/lib/plsql/procedure_call.rb +53 -4
- data/lib/plsql/schema.rb +114 -45
- data/lib/plsql/sequence.rb +1 -1
- data/lib/plsql/sql_statements.rb +7 -2
- data/lib/plsql/table.rb +80 -25
- data/lib/plsql/type.rb +87 -0
- data/lib/plsql/variable.rb +146 -0
- data/lib/plsql/version.rb +1 -1
- data/lib/plsql/view.rb +41 -0
- data/lib/ruby_plsql.rb +1 -1
- data/spec/plsql/connection_spec.rb +112 -50
- data/spec/plsql/package_spec.rb +19 -10
- data/spec/plsql/procedure_spec.rb +159 -126
- data/spec/plsql/schema_spec.rb +109 -1
- data/spec/plsql/sql_statements_spec.rb +14 -32
- data/spec/plsql/table_spec.rb +75 -9
- data/spec/plsql/type_spec.rb +133 -0
- data/spec/plsql/variable_spec.rb +458 -0
- data/spec/plsql/version_spec.rb +8 -0
- data/spec/plsql/view_spec.rb +259 -0
- data/spec/spec_helper.rb +1 -1
- metadata +15 -2
data/lib/ruby_plsql.rb
CHANGED
@@ -2,7 +2,7 @@ require "time"
|
|
2
2
|
require "date"
|
3
3
|
require "bigdecimal"
|
4
4
|
|
5
|
-
%w(connection sql_statements schema procedure procedure_call package table sequence).each do |file|
|
5
|
+
%w(connection sql_statements schema procedure procedure_call package variable table view sequence type version helpers).each do |file|
|
6
6
|
require "plsql/#{file}"
|
7
7
|
end
|
8
8
|
|
@@ -6,42 +6,46 @@ describe "Connection" do
|
|
6
6
|
|
7
7
|
before(:all) do
|
8
8
|
@raw_conn = get_connection
|
9
|
+
@conn = PLSQL::Connection.create( @raw_conn )
|
9
10
|
end
|
10
11
|
|
11
12
|
after(:all) do
|
12
|
-
unless defined?(
|
13
|
+
unless defined?(JRuby)
|
13
14
|
@raw_conn.logoff rescue nil
|
14
15
|
else
|
15
16
|
@raw_conn.close rescue nil
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
describe "create and destroy" do
|
21
|
+
before(:each) do
|
22
|
+
@conn = PLSQL::Connection.create( @raw_conn )
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
it "should create connection" do
|
26
|
+
@conn.raw_connection.should == @raw_conn
|
27
|
+
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
unless defined?(JRuby)
|
30
|
+
it "should be oci connection" do
|
31
|
+
@conn.should be_oci
|
32
|
+
@conn.raw_driver.should == :oci
|
33
|
+
end
|
34
|
+
else
|
35
|
+
it "should be jdbc connection" do
|
36
|
+
@conn.should be_jdbc
|
37
|
+
@conn.raw_driver.should == :jdbc
|
38
|
+
end
|
31
39
|
end
|
32
|
-
|
33
|
-
it "should
|
34
|
-
@conn.should
|
35
|
-
@conn.raw_driver.should == :jdbc
|
40
|
+
|
41
|
+
it "should logoff connection" do
|
42
|
+
@conn.logoff.should be_true
|
36
43
|
end
|
44
|
+
|
37
45
|
end
|
38
|
-
|
39
|
-
it "should logoff connection" do
|
40
|
-
@conn.logoff.should be_true
|
41
|
-
end
|
42
|
-
|
46
|
+
|
43
47
|
# Ruby 1.8 and 1.9
|
44
|
-
|
48
|
+
unless defined?(JRuby)
|
45
49
|
describe "OCI data type conversions" do
|
46
50
|
it "should translate PL/SQL VARCHAR2 to Ruby String" do
|
47
51
|
@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100).should == [String, 100]
|
@@ -110,8 +114,9 @@ describe "Connection" do
|
|
110
114
|
|
111
115
|
end
|
112
116
|
|
113
|
-
|
114
|
-
|
117
|
+
# JRuby
|
118
|
+
else
|
119
|
+
|
115
120
|
describe "JDBC data type conversions" do
|
116
121
|
it "should translate PL/SQL VARCHAR2 to Ruby String" do
|
117
122
|
@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100).should == [String, 100]
|
@@ -123,7 +128,7 @@ describe "Connection" do
|
|
123
128
|
end
|
124
129
|
|
125
130
|
it "should translate PL/SQL DATE to Ruby DateTime" do
|
126
|
-
@conn.plsql_to_ruby_data_type(:data_type => "DATE", :data_length => nil).should == [
|
131
|
+
@conn.plsql_to_ruby_data_type(:data_type => "DATE", :data_length => nil).should == [DateTime, nil]
|
127
132
|
end
|
128
133
|
|
129
134
|
it "should translate PL/SQL TIMESTAMP to Ruby Time" do
|
@@ -138,12 +143,7 @@ describe "Connection" do
|
|
138
143
|
big_decimal = @conn.ruby_value_to_ora_value(12345678901234567890, BigDecimal)
|
139
144
|
big_decimal.should == java.math.BigDecimal.new("12345678901234567890")
|
140
145
|
end
|
141
|
-
|
142
|
-
# it "should translate Ruby OraDate value to DateTime when DateTime type specified" do
|
143
|
-
# now = OraDate.now
|
144
|
-
# @conn.ruby_value_to_ora_value(now, DateTime).should eql(now.to_datetime)
|
145
|
-
# end
|
146
|
-
|
146
|
+
|
147
147
|
it "should translate Ruby String value to Java::OracleSql::CLOB when Java::OracleSql::CLOB type specified" do
|
148
148
|
large_text = "x" * 100_000
|
149
149
|
ora_value = @conn.ruby_value_to_ora_value(large_text, Java::OracleSql::CLOB)
|
@@ -166,11 +166,6 @@ describe "Connection" do
|
|
166
166
|
it "should translate Oracle BigDecimal float value to BigDecimal" do
|
167
167
|
@conn.ora_value_to_ruby_value(BigDecimal("100.11")).should eql(BigDecimal("100.11"))
|
168
168
|
end
|
169
|
-
|
170
|
-
# it "should translate Oracle OraDate value to Time" do
|
171
|
-
# now = OraDate.now
|
172
|
-
# @conn.ora_value_to_ruby_value(now).should eql(now.to_time)
|
173
|
-
# end
|
174
169
|
|
175
170
|
it "should translate Oracle CLOB value to String" do
|
176
171
|
large_text = "āčē" * 100_000
|
@@ -185,8 +180,8 @@ describe "Connection" do
|
|
185
180
|
end
|
186
181
|
|
187
182
|
end
|
188
|
-
|
189
|
-
end
|
183
|
+
|
184
|
+
end
|
190
185
|
|
191
186
|
describe "SQL SELECT statements" do
|
192
187
|
|
@@ -218,7 +213,7 @@ describe "Connection" do
|
|
218
213
|
FROM dual").should == [nil,123,123.456,@now]
|
219
214
|
end
|
220
215
|
|
221
|
-
if defined?(
|
216
|
+
if defined?(JRuby)
|
222
217
|
|
223
218
|
it "should execute SQL statement with NULL values as bind parameters and return first result" do
|
224
219
|
@today = Date.parse("2008-05-31")
|
@@ -278,30 +273,30 @@ describe "Connection" do
|
|
278
273
|
end
|
279
274
|
|
280
275
|
describe "PL/SQL procedures" do
|
281
|
-
before(:
|
276
|
+
before(:all) do
|
282
277
|
@random = rand(1000)
|
283
278
|
@now = Time.local(2008,05,31,23,22,11)
|
284
|
-
sql = <<-
|
279
|
+
sql = <<-SQL
|
285
280
|
CREATE OR REPLACE FUNCTION test_add_random (p_number NUMBER, p_varchar IN OUT VARCHAR2, p_date IN OUT DATE)
|
286
281
|
RETURN NUMBER
|
287
282
|
IS
|
288
283
|
BEGIN
|
289
284
|
RETURN p_number + #{@random};
|
290
285
|
END test_add_random;
|
291
|
-
|
286
|
+
SQL
|
292
287
|
@conn.exec(sql).should be_true
|
293
288
|
end
|
294
289
|
|
295
|
-
after(:
|
290
|
+
after(:all) do
|
296
291
|
@conn.exec "DROP FUNCTION test_add_random"
|
297
292
|
end
|
298
293
|
|
299
294
|
it "should parse PL/SQL procedure call and bind parameters and exec and get bind parameter value" do
|
300
|
-
sql = <<-
|
295
|
+
sql = <<-SQL
|
301
296
|
BEGIN
|
302
297
|
:result := test_add_random (:p_number, :p_varchar, :p_date);
|
303
298
|
END;
|
304
|
-
|
299
|
+
SQL
|
305
300
|
cursor = @conn.parse(sql)
|
306
301
|
cursor.bind_param(":result", nil, :data_type => 'NUMBER', :in_out => 'OUT')
|
307
302
|
cursor.bind_param(":p_number", 100, :data_type => 'NUMBER', :in_out => 'IN')
|
@@ -317,17 +312,21 @@ describe "Connection" do
|
|
317
312
|
end
|
318
313
|
|
319
314
|
describe "commit and rollback" do
|
320
|
-
before(:
|
321
|
-
|
322
|
-
@conn.exec(sql).should be_true
|
315
|
+
before(:all) do
|
316
|
+
@conn.exec("CREATE TABLE test_commit (dummy VARCHAR2(100))").should be_true
|
323
317
|
@conn.autocommit = false
|
324
318
|
@conn.should_not be_autocommit
|
325
319
|
end
|
320
|
+
|
321
|
+
after(:all) do
|
322
|
+
@conn.exec "DROP TABLE test_commit"
|
323
|
+
end
|
324
|
+
|
326
325
|
after(:each) do
|
327
|
-
|
328
|
-
@conn.
|
326
|
+
@conn.exec "DELETE FROM test_commit"
|
327
|
+
@conn.commit
|
329
328
|
end
|
330
|
-
|
329
|
+
|
331
330
|
it "should do commit" do
|
332
331
|
@conn.exec("INSERT INTO test_commit VALUES ('test')")
|
333
332
|
@conn.commit
|
@@ -349,4 +348,67 @@ describe "Connection" do
|
|
349
348
|
|
350
349
|
end
|
351
350
|
|
351
|
+
describe "prefetch rows" do
|
352
|
+
after(:each) do
|
353
|
+
@conn.prefetch_rows = 1 # set back to default
|
354
|
+
end
|
355
|
+
|
356
|
+
it "should set prefetch rows for connection" do
|
357
|
+
sql = "SELECT 1 FROM dual UNION ALL SELECT 1/0 FROM dual"
|
358
|
+
@conn.prefetch_rows = 2
|
359
|
+
lambda {
|
360
|
+
@conn.cursor_from_query(sql)
|
361
|
+
}.should raise_error(/divisor is equal to zero/)
|
362
|
+
@conn.prefetch_rows = 1
|
363
|
+
lambda {
|
364
|
+
@conn.cursor_from_query(sql)
|
365
|
+
}.should_not raise_error
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should fetch just one row when using select_first" do
|
369
|
+
sql = "SELECT 1 FROM dual UNION ALL SELECT 1/0 FROM dual"
|
370
|
+
@conn.prefetch_rows = 2
|
371
|
+
lambda {
|
372
|
+
@conn.select_first(sql)
|
373
|
+
}.should_not raise_error
|
374
|
+
end
|
375
|
+
|
376
|
+
end
|
377
|
+
|
378
|
+
describe "describe synonym" do
|
379
|
+
before(:all) do
|
380
|
+
@conn.exec "CREATE SYNONYM hr.synonym_for_dual FOR sys.dual"
|
381
|
+
end
|
382
|
+
|
383
|
+
after(:all) do
|
384
|
+
@conn.exec "DROP SYNONYM hr.synonym_for_dual"
|
385
|
+
end
|
386
|
+
|
387
|
+
it "should describe local synonym" do
|
388
|
+
@conn.describe_synonym('HR','SYNONYM_FOR_DUAL').should == ['SYS', 'DUAL']
|
389
|
+
@conn.describe_synonym('hr','synonym_for_dual').should == ['SYS', 'DUAL']
|
390
|
+
@conn.describe_synonym(:hr,:synonym_for_dual).should == ['SYS', 'DUAL']
|
391
|
+
end
|
392
|
+
|
393
|
+
it "should return nil on non-existing synonym" do
|
394
|
+
@conn.describe_synonym('HR','SYNONYM_FOR_XXX').should be_nil
|
395
|
+
@conn.describe_synonym('hr','synonym_for_xxx').should be_nil
|
396
|
+
@conn.describe_synonym(:hr,:synonym_for_xxx).should be_nil
|
397
|
+
end
|
398
|
+
|
399
|
+
it "should describe public synonym" do
|
400
|
+
@conn.describe_synonym('PUBLIC','DUAL').should == ['SYS', 'DUAL']
|
401
|
+
@conn.describe_synonym('PUBLIC','dual').should == ['SYS', 'DUAL']
|
402
|
+
@conn.describe_synonym('PUBLIC',:dual).should == ['SYS', 'DUAL']
|
403
|
+
end
|
404
|
+
|
405
|
+
end
|
406
|
+
|
407
|
+
describe "database version" do
|
408
|
+
it "should get database version" do
|
409
|
+
# using Oracle version 10.2.0.4 for unit tests
|
410
|
+
@conn.database_version.should == [10, 2]
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
352
414
|
end
|
data/spec/plsql/package_spec.rb
CHANGED
@@ -3,13 +3,14 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe "Package" do
|
4
4
|
before(:all) do
|
5
5
|
plsql.connection = get_connection
|
6
|
-
plsql.
|
6
|
+
plsql.execute <<-SQL
|
7
7
|
CREATE OR REPLACE PACKAGE test_package IS
|
8
|
+
test_variable NUMBER;
|
8
9
|
FUNCTION test_procedure ( p_string VARCHAR2 )
|
9
10
|
RETURN VARCHAR2;
|
10
11
|
END;
|
11
|
-
|
12
|
-
plsql.
|
12
|
+
SQL
|
13
|
+
plsql.execute <<-SQL
|
13
14
|
CREATE OR REPLACE PACKAGE BODY test_package IS
|
14
15
|
FUNCTION test_procedure ( p_string VARCHAR2 )
|
15
16
|
RETURN VARCHAR2
|
@@ -18,11 +19,12 @@ describe "Package" do
|
|
18
19
|
RETURN UPPER(p_string);
|
19
20
|
END test_procedure;
|
20
21
|
END;
|
21
|
-
|
22
|
+
SQL
|
22
23
|
|
23
24
|
end
|
24
25
|
|
25
26
|
after(:all) do
|
27
|
+
plsql.execute "DROP PACKAGE test_package"
|
26
28
|
plsql.logoff
|
27
29
|
end
|
28
30
|
|
@@ -45,19 +47,26 @@ describe "Package" do
|
|
45
47
|
plsql.test_package.test_procedure('xxx').should == 'XXX'
|
46
48
|
end
|
47
49
|
|
50
|
+
describe "variables" do
|
51
|
+
it "should set and get package variable value" do
|
52
|
+
plsql.test_package.test_variable = 1
|
53
|
+
plsql.test_package.test_variable.should == 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
end
|
49
58
|
|
50
59
|
describe "Synonym to package" do
|
51
60
|
|
52
61
|
before(:all) do
|
53
62
|
plsql.connection = get_connection
|
54
|
-
plsql.
|
63
|
+
plsql.execute <<-SQL
|
55
64
|
CREATE OR REPLACE PACKAGE hr.test_package IS
|
56
65
|
FUNCTION test_procedure ( p_string VARCHAR2 )
|
57
66
|
RETURN VARCHAR2;
|
58
67
|
END;
|
59
|
-
|
60
|
-
plsql.
|
68
|
+
SQL
|
69
|
+
plsql.execute <<-SQL
|
61
70
|
CREATE OR REPLACE PACKAGE BODY hr.test_package IS
|
62
71
|
FUNCTION test_procedure ( p_string VARCHAR2 )
|
63
72
|
RETURN VARCHAR2
|
@@ -66,12 +75,12 @@ describe "Synonym to package" do
|
|
66
75
|
RETURN UPPER(p_string);
|
67
76
|
END test_procedure;
|
68
77
|
END;
|
69
|
-
|
70
|
-
plsql.
|
78
|
+
SQL
|
79
|
+
plsql.execute "CREATE SYNONYM test_pkg_synonym FOR hr.test_package"
|
71
80
|
end
|
72
81
|
|
73
82
|
after(:all) do
|
74
|
-
plsql.
|
83
|
+
plsql.execute "DROP SYNONYM test_pkg_synonym" rescue nil
|
75
84
|
plsql.logoff
|
76
85
|
end
|
77
86
|
|
@@ -14,7 +14,7 @@ describe "Parameter type mapping /" do
|
|
14
14
|
describe "Function with string parameters" do
|
15
15
|
|
16
16
|
before(:all) do
|
17
|
-
plsql.
|
17
|
+
plsql.execute <<-SQL
|
18
18
|
CREATE OR REPLACE FUNCTION test_uppercase
|
19
19
|
( p_string VARCHAR2 )
|
20
20
|
RETURN VARCHAR2
|
@@ -22,11 +22,11 @@ describe "Parameter type mapping /" do
|
|
22
22
|
BEGIN
|
23
23
|
RETURN UPPER(p_string);
|
24
24
|
END test_uppercase;
|
25
|
-
|
25
|
+
SQL
|
26
26
|
end
|
27
27
|
|
28
28
|
after(:all) do
|
29
|
-
plsql.
|
29
|
+
plsql.execute "DROP FUNCTION test_uppercase"
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should find existing procedure" do
|
@@ -66,7 +66,7 @@ describe "Parameter type mapping /" do
|
|
66
66
|
describe "Function with numeric parameters" do
|
67
67
|
|
68
68
|
before(:all) do
|
69
|
-
plsql.
|
69
|
+
plsql.execute <<-SQL
|
70
70
|
CREATE OR REPLACE FUNCTION test_sum
|
71
71
|
( p_num1 NUMBER, p_num2 NUMBER )
|
72
72
|
RETURN NUMBER
|
@@ -75,7 +75,7 @@ describe "Parameter type mapping /" do
|
|
75
75
|
RETURN p_num1 + p_num2;
|
76
76
|
END test_sum;
|
77
77
|
SQL
|
78
|
-
plsql.
|
78
|
+
plsql.execute <<-SQL
|
79
79
|
CREATE OR REPLACE FUNCTION test_number_1
|
80
80
|
( p_num NUMBER )
|
81
81
|
RETURN VARCHAR2
|
@@ -92,11 +92,21 @@ describe "Parameter type mapping /" do
|
|
92
92
|
END IF;
|
93
93
|
END test_number_1;
|
94
94
|
SQL
|
95
|
+
plsql.execute <<-SQL
|
96
|
+
CREATE OR REPLACE PROCEDURE test_integers
|
97
|
+
( p_pls_int PLS_INTEGER, p_bin_int BINARY_INTEGER, x_pls_int OUT PLS_INTEGER, x_bin_int OUT BINARY_INTEGER )
|
98
|
+
IS
|
99
|
+
BEGIN
|
100
|
+
x_pls_int := p_pls_int;
|
101
|
+
x_bin_int := p_bin_int;
|
102
|
+
END;
|
103
|
+
SQL
|
95
104
|
end
|
96
105
|
|
97
106
|
after(:all) do
|
98
|
-
plsql.
|
99
|
-
plsql.
|
107
|
+
plsql.execute "DROP FUNCTION test_sum"
|
108
|
+
plsql.execute "DROP FUNCTION test_number_1"
|
109
|
+
plsql.execute "DROP PROCEDURE test_integers"
|
100
110
|
end
|
101
111
|
|
102
112
|
it "should process integer parameters" do
|
@@ -127,12 +137,15 @@ describe "Parameter type mapping /" do
|
|
127
137
|
plsql.test_number_1(false).should == 'N'
|
128
138
|
end
|
129
139
|
|
140
|
+
it "should process binary integer parameters" do
|
141
|
+
plsql.test_integers(123, 456).should == {:x_pls_int => 123, :x_bin_int => 456}
|
142
|
+
end
|
130
143
|
end
|
131
144
|
|
132
145
|
describe "Function with date parameters" do
|
133
146
|
|
134
147
|
before(:all) do
|
135
|
-
plsql.
|
148
|
+
plsql.execute <<-SQL
|
136
149
|
CREATE OR REPLACE FUNCTION test_date
|
137
150
|
( p_date DATE )
|
138
151
|
RETURN DATE
|
@@ -140,7 +153,7 @@ describe "Parameter type mapping /" do
|
|
140
153
|
BEGIN
|
141
154
|
RETURN p_date + 1;
|
142
155
|
END test_date;
|
143
|
-
|
156
|
+
SQL
|
144
157
|
end
|
145
158
|
|
146
159
|
before(:each) do
|
@@ -148,7 +161,7 @@ describe "Parameter type mapping /" do
|
|
148
161
|
end
|
149
162
|
|
150
163
|
after(:all) do
|
151
|
-
plsql.
|
164
|
+
plsql.execute "DROP FUNCTION test_date"
|
152
165
|
end
|
153
166
|
|
154
167
|
it "should process Time parameters" do
|
@@ -199,7 +212,7 @@ describe "Parameter type mapping /" do
|
|
199
212
|
describe "Function with timestamp parameters" do
|
200
213
|
|
201
214
|
before(:all) do
|
202
|
-
plsql.
|
215
|
+
plsql.execute <<-SQL
|
203
216
|
CREATE OR REPLACE FUNCTION test_timestamp
|
204
217
|
( p_time TIMESTAMP )
|
205
218
|
RETURN TIMESTAMP
|
@@ -207,11 +220,11 @@ describe "Parameter type mapping /" do
|
|
207
220
|
BEGIN
|
208
221
|
RETURN p_time + NUMTODSINTERVAL(1, 'DAY');
|
209
222
|
END test_timestamp;
|
210
|
-
|
223
|
+
SQL
|
211
224
|
end
|
212
225
|
|
213
226
|
after(:all) do
|
214
|
-
plsql.
|
227
|
+
plsql.execute "DROP FUNCTION test_timestamp"
|
215
228
|
end
|
216
229
|
|
217
230
|
it "should process timestamp parameters" do
|
@@ -224,7 +237,7 @@ describe "Parameter type mapping /" do
|
|
224
237
|
|
225
238
|
describe "Procedure with output parameters" do
|
226
239
|
before(:all) do
|
227
|
-
plsql.
|
240
|
+
plsql.execute <<-SQL
|
228
241
|
CREATE OR REPLACE PROCEDURE test_copy
|
229
242
|
( p_from VARCHAR2, p_to OUT VARCHAR2, p_to_double OUT VARCHAR2 )
|
230
243
|
IS
|
@@ -232,11 +245,11 @@ describe "Parameter type mapping /" do
|
|
232
245
|
p_to := p_from;
|
233
246
|
p_to_double := p_from || p_from;
|
234
247
|
END test_copy;
|
235
|
-
|
248
|
+
SQL
|
236
249
|
end
|
237
250
|
|
238
251
|
after(:all) do
|
239
|
-
plsql.
|
252
|
+
plsql.execute "DROP PROCEDURE test_copy"
|
240
253
|
end
|
241
254
|
|
242
255
|
it "should return hash with output parameters" do
|
@@ -259,7 +272,7 @@ describe "Parameter type mapping /" do
|
|
259
272
|
|
260
273
|
describe "Package with procedures with same name but different argument lists" do
|
261
274
|
before(:all) do
|
262
|
-
plsql.
|
275
|
+
plsql.execute <<-SQL
|
263
276
|
CREATE OR REPLACE PACKAGE test_package2 IS
|
264
277
|
FUNCTION test_procedure ( p_string VARCHAR2 )
|
265
278
|
RETURN VARCHAR2;
|
@@ -270,8 +283,8 @@ describe "Parameter type mapping /" do
|
|
270
283
|
FUNCTION test_procedure2 ( p_string VARCHAR2 )
|
271
284
|
RETURN VARCHAR2;
|
272
285
|
END;
|
273
|
-
|
274
|
-
plsql.
|
286
|
+
SQL
|
287
|
+
plsql.execute <<-SQL
|
275
288
|
CREATE OR REPLACE PACKAGE BODY test_package2 IS
|
276
289
|
FUNCTION test_procedure ( p_string VARCHAR2 )
|
277
290
|
RETURN VARCHAR2
|
@@ -296,12 +309,12 @@ describe "Parameter type mapping /" do
|
|
296
309
|
RETURN UPPER(p_string);
|
297
310
|
END test_procedure2;
|
298
311
|
END;
|
299
|
-
|
312
|
+
SQL
|
300
313
|
|
301
314
|
end
|
302
315
|
|
303
316
|
after(:all) do
|
304
|
-
plsql.
|
317
|
+
plsql.execute "DROP PACKAGE test_package2"
|
305
318
|
end
|
306
319
|
|
307
320
|
it "should find existing package" do
|
@@ -347,7 +360,7 @@ describe "Parameter type mapping /" do
|
|
347
360
|
|
348
361
|
describe "Function with output parameters" do
|
349
362
|
before(:all) do
|
350
|
-
plsql.
|
363
|
+
plsql.execute <<-SQL
|
351
364
|
CREATE OR REPLACE FUNCTION test_copy_function
|
352
365
|
( p_from VARCHAR2, p_to OUT VARCHAR2, p_to_double OUT VARCHAR2 )
|
353
366
|
RETURN NUMBER
|
@@ -357,11 +370,11 @@ describe "Parameter type mapping /" do
|
|
357
370
|
p_to_double := p_from || p_from;
|
358
371
|
RETURN LENGTH(p_from);
|
359
372
|
END test_copy_function;
|
360
|
-
|
373
|
+
SQL
|
361
374
|
end
|
362
375
|
|
363
376
|
after(:all) do
|
364
|
-
plsql.
|
377
|
+
plsql.execute "DROP FUNCTION test_copy_function"
|
365
378
|
end
|
366
379
|
|
367
380
|
it "should return array with return value and hash of output parameters" do
|
@@ -381,26 +394,26 @@ describe "Parameter type mapping /" do
|
|
381
394
|
|
382
395
|
describe "Function or procedure without parameters" do
|
383
396
|
before(:all) do
|
384
|
-
plsql.
|
397
|
+
plsql.execute <<-SQL
|
385
398
|
CREATE OR REPLACE FUNCTION test_no_params
|
386
399
|
RETURN VARCHAR2
|
387
400
|
IS
|
388
401
|
BEGIN
|
389
402
|
RETURN 'dummy';
|
390
403
|
END test_no_params;
|
391
|
-
|
392
|
-
plsql.
|
404
|
+
SQL
|
405
|
+
plsql.execute <<-SQL
|
393
406
|
CREATE OR REPLACE PROCEDURE test_proc_no_params
|
394
407
|
IS
|
395
408
|
BEGIN
|
396
409
|
NULL;
|
397
410
|
END test_proc_no_params;
|
398
|
-
|
411
|
+
SQL
|
399
412
|
end
|
400
413
|
|
401
414
|
after(:all) do
|
402
|
-
plsql.
|
403
|
-
plsql.
|
415
|
+
plsql.execute "DROP FUNCTION test_no_params"
|
416
|
+
plsql.execute "DROP PROCEDURE test_proc_no_params"
|
404
417
|
end
|
405
418
|
|
406
419
|
it "should find function" do
|
@@ -424,7 +437,7 @@ describe "Parameter type mapping /" do
|
|
424
437
|
describe "Function with CLOB parameter and return value" do
|
425
438
|
|
426
439
|
before(:all) do
|
427
|
-
plsql.
|
440
|
+
plsql.execute <<-SQL
|
428
441
|
CREATE OR REPLACE FUNCTION test_clob
|
429
442
|
( p_clob CLOB )
|
430
443
|
RETURN CLOB
|
@@ -432,11 +445,11 @@ describe "Parameter type mapping /" do
|
|
432
445
|
BEGIN
|
433
446
|
RETURN p_clob;
|
434
447
|
END test_clob;
|
435
|
-
|
448
|
+
SQL
|
436
449
|
end
|
437
450
|
|
438
451
|
after(:all) do
|
439
|
-
plsql.
|
452
|
+
plsql.execute "DROP FUNCTION test_clob"
|
440
453
|
end
|
441
454
|
|
442
455
|
it "should find existing procedure" do
|
@@ -473,7 +486,7 @@ describe "Parameter type mapping /" do
|
|
473
486
|
describe "Procedrue with CLOB parameter and return value" do
|
474
487
|
|
475
488
|
before(:all) do
|
476
|
-
plsql.
|
489
|
+
plsql.execute <<-SQL
|
477
490
|
CREATE OR REPLACE PROCEDURE test_clob_proc
|
478
491
|
( p_clob CLOB,
|
479
492
|
p_return OUT CLOB)
|
@@ -481,11 +494,11 @@ describe "Parameter type mapping /" do
|
|
481
494
|
BEGIN
|
482
495
|
p_return := p_clob;
|
483
496
|
END test_clob_proc;
|
484
|
-
|
497
|
+
SQL
|
485
498
|
end
|
486
499
|
|
487
500
|
after(:all) do
|
488
|
-
plsql.
|
501
|
+
plsql.execute "DROP PROCEDURE test_clob_proc"
|
489
502
|
end
|
490
503
|
|
491
504
|
it "should find existing procedure" do
|
@@ -501,7 +514,7 @@ describe "Parameter type mapping /" do
|
|
501
514
|
describe "Procedrue with BLOB parameter and return value" do
|
502
515
|
|
503
516
|
before(:all) do
|
504
|
-
plsql.
|
517
|
+
plsql.execute <<-SQL
|
505
518
|
CREATE OR REPLACE PROCEDURE test_blob_proc
|
506
519
|
( p_blob BLOB,
|
507
520
|
p_return OUT BLOB)
|
@@ -509,11 +522,11 @@ describe "Parameter type mapping /" do
|
|
509
522
|
BEGIN
|
510
523
|
p_return := p_blob;
|
511
524
|
END test_blob_proc;
|
512
|
-
|
525
|
+
SQL
|
513
526
|
end
|
514
527
|
|
515
528
|
after(:all) do
|
516
|
-
plsql.
|
529
|
+
plsql.execute "DROP PROCEDURE test_blob_proc"
|
517
530
|
end
|
518
531
|
|
519
532
|
it "should find existing procedure" do
|
@@ -529,8 +542,8 @@ describe "Parameter type mapping /" do
|
|
529
542
|
describe "Function with record parameter" do
|
530
543
|
|
531
544
|
before(:all) do
|
532
|
-
plsql.
|
533
|
-
plsql.
|
545
|
+
plsql.execute "DROP TABLE test_employees" rescue nil
|
546
|
+
plsql.execute <<-SQL
|
534
547
|
CREATE TABLE test_employees (
|
535
548
|
employee_id NUMBER(15),
|
536
549
|
first_name VARCHAR2(50),
|
@@ -538,7 +551,7 @@ describe "Parameter type mapping /" do
|
|
538
551
|
hire_date DATE
|
539
552
|
)
|
540
553
|
SQL
|
541
|
-
plsql.
|
554
|
+
plsql.execute <<-SQL
|
542
555
|
CREATE OR REPLACE FUNCTION test_full_name (p_employee test_employees%ROWTYPE)
|
543
556
|
RETURN VARCHAR2
|
544
557
|
IS
|
@@ -546,7 +559,7 @@ describe "Parameter type mapping /" do
|
|
546
559
|
RETURN p_employee.first_name || ' ' || p_employee.last_name;
|
547
560
|
END test_full_name;
|
548
561
|
SQL
|
549
|
-
plsql.
|
562
|
+
plsql.execute <<-SQL
|
550
563
|
CREATE OR REPLACE FUNCTION test_employee_record (p_employee test_employees%ROWTYPE)
|
551
564
|
RETURN test_employees%ROWTYPE
|
552
565
|
IS
|
@@ -554,7 +567,7 @@ describe "Parameter type mapping /" do
|
|
554
567
|
RETURN p_employee;
|
555
568
|
END test_employee_record;
|
556
569
|
SQL
|
557
|
-
plsql.
|
570
|
+
plsql.execute <<-SQL
|
558
571
|
CREATE OR REPLACE FUNCTION test_employee_record2 (p_employee test_employees%ROWTYPE, x_employee OUT test_employees%ROWTYPE)
|
559
572
|
RETURN test_employees%ROWTYPE
|
560
573
|
IS
|
@@ -581,10 +594,10 @@ describe "Parameter type mapping /" do
|
|
581
594
|
end
|
582
595
|
|
583
596
|
after(:all) do
|
584
|
-
plsql.
|
585
|
-
plsql.
|
586
|
-
plsql.
|
587
|
-
plsql.
|
597
|
+
plsql.execute "DROP FUNCTION test_full_name"
|
598
|
+
plsql.execute "DROP FUNCTION test_employee_record"
|
599
|
+
plsql.execute "DROP FUNCTION test_employee_record2"
|
600
|
+
plsql.execute "DROP TABLE test_employees"
|
588
601
|
end
|
589
602
|
|
590
603
|
it "should find existing function" do
|
@@ -622,7 +635,7 @@ describe "Parameter type mapping /" do
|
|
622
635
|
describe "Function with boolean parameters" do
|
623
636
|
|
624
637
|
before(:all) do
|
625
|
-
plsql.
|
638
|
+
plsql.execute <<-SQL
|
626
639
|
CREATE OR REPLACE FUNCTION test_boolean
|
627
640
|
( p_boolean BOOLEAN )
|
628
641
|
RETURN BOOLEAN
|
@@ -631,7 +644,7 @@ describe "Parameter type mapping /" do
|
|
631
644
|
RETURN p_boolean;
|
632
645
|
END test_boolean;
|
633
646
|
SQL
|
634
|
-
plsql.
|
647
|
+
plsql.execute <<-SQL
|
635
648
|
CREATE OR REPLACE PROCEDURE test_boolean2
|
636
649
|
( p_boolean BOOLEAN, x_boolean OUT BOOLEAN )
|
637
650
|
IS
|
@@ -642,8 +655,8 @@ describe "Parameter type mapping /" do
|
|
642
655
|
end
|
643
656
|
|
644
657
|
after(:all) do
|
645
|
-
plsql.
|
646
|
-
plsql.
|
658
|
+
plsql.execute "DROP FUNCTION test_boolean"
|
659
|
+
plsql.execute "DROP PROCEDURE test_boolean2"
|
647
660
|
end
|
648
661
|
|
649
662
|
it "should accept true value and return true value" do
|
@@ -675,25 +688,25 @@ describe "Parameter type mapping /" do
|
|
675
688
|
describe "Function with object type parameter" do
|
676
689
|
|
677
690
|
before(:all) do
|
678
|
-
plsql.
|
679
|
-
plsql.
|
680
|
-
plsql.
|
691
|
+
plsql.execute "DROP TYPE t_employee" rescue nil
|
692
|
+
plsql.execute "DROP TYPE t_phones" rescue nil
|
693
|
+
plsql.execute <<-SQL
|
681
694
|
CREATE OR REPLACE TYPE t_address AS OBJECT (
|
682
695
|
street VARCHAR2(50),
|
683
696
|
city VARCHAR2(50),
|
684
697
|
country VARCHAR2(50)
|
685
698
|
)
|
686
699
|
SQL
|
687
|
-
plsql.
|
700
|
+
plsql.execute <<-SQL
|
688
701
|
CREATE OR REPLACE TYPE t_phone AS OBJECT (
|
689
702
|
type VARCHAR2(10),
|
690
703
|
phone_number VARCHAR2(50)
|
691
704
|
)
|
692
705
|
SQL
|
693
|
-
plsql.
|
706
|
+
plsql.execute <<-SQL
|
694
707
|
CREATE OR REPLACE TYPE t_phones AS TABLE OF T_PHONE
|
695
708
|
SQL
|
696
|
-
plsql.
|
709
|
+
plsql.execute <<-SQL
|
697
710
|
CREATE OR REPLACE TYPE t_employee AS OBJECT (
|
698
711
|
employee_id NUMBER(15),
|
699
712
|
first_name VARCHAR2(50),
|
@@ -703,7 +716,7 @@ describe "Parameter type mapping /" do
|
|
703
716
|
phones t_phones
|
704
717
|
)
|
705
718
|
SQL
|
706
|
-
plsql.
|
719
|
+
plsql.execute <<-SQL
|
707
720
|
CREATE OR REPLACE FUNCTION test_full_name (p_employee t_employee)
|
708
721
|
RETURN VARCHAR2
|
709
722
|
IS
|
@@ -711,7 +724,7 @@ describe "Parameter type mapping /" do
|
|
711
724
|
RETURN p_employee.first_name || ' ' || p_employee.last_name;
|
712
725
|
END;
|
713
726
|
SQL
|
714
|
-
plsql.
|
727
|
+
plsql.execute <<-SQL
|
715
728
|
CREATE OR REPLACE FUNCTION test_employee_object (p_employee t_employee)
|
716
729
|
RETURN t_employee
|
717
730
|
IS
|
@@ -719,7 +732,7 @@ describe "Parameter type mapping /" do
|
|
719
732
|
RETURN p_employee;
|
720
733
|
END;
|
721
734
|
SQL
|
722
|
-
plsql.
|
735
|
+
plsql.execute <<-SQL
|
723
736
|
CREATE OR REPLACE FUNCTION test_employee_object2 (p_employee t_employee, x_employee OUT t_employee)
|
724
737
|
RETURN t_employee
|
725
738
|
IS
|
@@ -739,13 +752,13 @@ describe "Parameter type mapping /" do
|
|
739
752
|
end
|
740
753
|
|
741
754
|
after(:all) do
|
742
|
-
plsql.
|
743
|
-
plsql.
|
744
|
-
plsql.
|
745
|
-
plsql.
|
746
|
-
plsql.
|
747
|
-
plsql.
|
748
|
-
plsql.
|
755
|
+
plsql.execute "DROP FUNCTION test_full_name"
|
756
|
+
plsql.execute "DROP FUNCTION test_employee_object"
|
757
|
+
plsql.execute "DROP FUNCTION test_employee_object2"
|
758
|
+
plsql.execute "DROP TYPE t_employee"
|
759
|
+
plsql.execute "DROP TYPE t_address"
|
760
|
+
plsql.execute "DROP TYPE t_phones"
|
761
|
+
plsql.execute "DROP TYPE t_phone"
|
749
762
|
end
|
750
763
|
|
751
764
|
it "should find existing function" do
|
@@ -781,10 +794,10 @@ describe "Parameter type mapping /" do
|
|
781
794
|
|
782
795
|
before(:all) do
|
783
796
|
# Array of numbers
|
784
|
-
plsql.
|
797
|
+
plsql.execute <<-SQL
|
785
798
|
CREATE OR REPLACE TYPE t_numbers AS TABLE OF NUMBER(15)
|
786
799
|
SQL
|
787
|
-
plsql.
|
800
|
+
plsql.execute <<-SQL
|
788
801
|
CREATE OR REPLACE FUNCTION test_sum (p_numbers IN t_numbers)
|
789
802
|
RETURN NUMBER
|
790
803
|
IS
|
@@ -803,7 +816,7 @@ describe "Parameter type mapping /" do
|
|
803
816
|
END;
|
804
817
|
SQL
|
805
818
|
|
806
|
-
plsql.
|
819
|
+
plsql.execute <<-SQL
|
807
820
|
CREATE OR REPLACE FUNCTION test_increment(p_numbers IN t_numbers, p_increment_by IN NUMBER DEFAULT 1)
|
808
821
|
RETURN t_numbers
|
809
822
|
IS
|
@@ -820,10 +833,10 @@ describe "Parameter type mapping /" do
|
|
820
833
|
SQL
|
821
834
|
|
822
835
|
# Array of strings
|
823
|
-
plsql.
|
836
|
+
plsql.execute <<-SQL
|
824
837
|
CREATE OR REPLACE TYPE t_strings AS TABLE OF VARCHAR2(4000)
|
825
838
|
SQL
|
826
|
-
plsql.
|
839
|
+
plsql.execute <<-SQL
|
827
840
|
CREATE OR REPLACE FUNCTION test_copy_strings(p_strings IN t_strings, x_strings OUT t_strings)
|
828
841
|
RETURN t_strings
|
829
842
|
IS
|
@@ -840,14 +853,14 @@ describe "Parameter type mapping /" do
|
|
840
853
|
SQL
|
841
854
|
|
842
855
|
# Wrong type definition inside package
|
843
|
-
plsql.
|
856
|
+
plsql.execute <<-SQL
|
844
857
|
CREATE OR REPLACE PACKAGE test_collections IS
|
845
858
|
TYPE t_numbers IS TABLE OF NUMBER(15);
|
846
859
|
FUNCTION test_sum (p_numbers IN t_numbers)
|
847
860
|
RETURN NUMBER;
|
848
861
|
END;
|
849
862
|
SQL
|
850
|
-
plsql.
|
863
|
+
plsql.execute <<-SQL
|
851
864
|
CREATE OR REPLACE PACKAGE BODY test_collections IS
|
852
865
|
FUNCTION test_sum (p_numbers IN t_numbers)
|
853
866
|
RETURN NUMBER
|
@@ -869,16 +882,16 @@ describe "Parameter type mapping /" do
|
|
869
882
|
SQL
|
870
883
|
|
871
884
|
# Array of objects
|
872
|
-
plsql.
|
885
|
+
plsql.execute <<-SQL
|
873
886
|
CREATE OR REPLACE TYPE t_phone AS OBJECT (
|
874
887
|
type VARCHAR2(10),
|
875
888
|
phone_number VARCHAR2(50)
|
876
889
|
)
|
877
890
|
SQL
|
878
|
-
plsql.
|
891
|
+
plsql.execute <<-SQL
|
879
892
|
CREATE OR REPLACE TYPE t_phones AS TABLE OF T_PHONE
|
880
893
|
SQL
|
881
|
-
plsql.
|
894
|
+
plsql.execute <<-SQL
|
882
895
|
CREATE OR REPLACE FUNCTION test_copy_objects(p_phones IN t_phones, x_phones OUT t_phones)
|
883
896
|
RETURN t_phones
|
884
897
|
IS
|
@@ -890,15 +903,15 @@ describe "Parameter type mapping /" do
|
|
890
903
|
end
|
891
904
|
|
892
905
|
after(:all) do
|
893
|
-
plsql.
|
894
|
-
plsql.
|
895
|
-
plsql.
|
896
|
-
plsql.
|
897
|
-
plsql.
|
898
|
-
plsql.
|
899
|
-
plsql.
|
900
|
-
plsql.
|
901
|
-
plsql.
|
906
|
+
plsql.execute "DROP FUNCTION test_sum"
|
907
|
+
plsql.execute "DROP FUNCTION test_increment"
|
908
|
+
plsql.execute "DROP FUNCTION test_copy_strings"
|
909
|
+
plsql.execute "DROP PACKAGE test_collections"
|
910
|
+
plsql.execute "DROP FUNCTION test_copy_objects"
|
911
|
+
plsql.execute "DROP TYPE t_numbers"
|
912
|
+
plsql.execute "DROP TYPE t_strings"
|
913
|
+
plsql.execute "DROP TYPE t_phones"
|
914
|
+
plsql.execute "DROP TYPE t_phone"
|
902
915
|
end
|
903
916
|
|
904
917
|
it "should find existing function" do
|
@@ -940,10 +953,10 @@ describe "Parameter type mapping /" do
|
|
940
953
|
|
941
954
|
before(:all) do
|
942
955
|
# Array of numbers
|
943
|
-
plsql.
|
956
|
+
plsql.execute <<-SQL
|
944
957
|
CREATE OR REPLACE TYPE t_numbers_array AS VARRAY(100) OF NUMBER(15)
|
945
958
|
SQL
|
946
|
-
plsql.
|
959
|
+
plsql.execute <<-SQL
|
947
960
|
CREATE OR REPLACE FUNCTION test_sum (p_numbers IN t_numbers_array)
|
948
961
|
RETURN NUMBER
|
949
962
|
IS
|
@@ -960,7 +973,7 @@ describe "Parameter type mapping /" do
|
|
960
973
|
END;
|
961
974
|
SQL
|
962
975
|
|
963
|
-
plsql.
|
976
|
+
plsql.execute <<-SQL
|
964
977
|
CREATE OR REPLACE FUNCTION test_increment(p_numbers IN t_numbers_array, p_increment_by IN NUMBER DEFAULT 1)
|
965
978
|
RETURN t_numbers_array
|
966
979
|
IS
|
@@ -975,10 +988,10 @@ describe "Parameter type mapping /" do
|
|
975
988
|
SQL
|
976
989
|
|
977
990
|
# Array of strings
|
978
|
-
plsql.
|
991
|
+
plsql.execute <<-SQL
|
979
992
|
CREATE OR REPLACE TYPE t_strings_array AS VARRAY(100) OF VARCHAR2(4000)
|
980
993
|
SQL
|
981
|
-
plsql.
|
994
|
+
plsql.execute <<-SQL
|
982
995
|
CREATE OR REPLACE FUNCTION test_copy_strings(p_strings IN t_strings_array, x_strings OUT t_strings_array)
|
983
996
|
RETURN t_strings_array
|
984
997
|
IS
|
@@ -993,17 +1006,17 @@ describe "Parameter type mapping /" do
|
|
993
1006
|
SQL
|
994
1007
|
|
995
1008
|
# Array of objects
|
996
|
-
plsql.
|
997
|
-
plsql.
|
1009
|
+
plsql.execute "DROP TYPE t_phones_array" rescue nil
|
1010
|
+
plsql.execute <<-SQL
|
998
1011
|
CREATE OR REPLACE TYPE t_phone AS OBJECT (
|
999
1012
|
type VARCHAR2(10),
|
1000
1013
|
phone_number VARCHAR2(50)
|
1001
1014
|
)
|
1002
1015
|
SQL
|
1003
|
-
plsql.
|
1016
|
+
plsql.execute <<-SQL
|
1004
1017
|
CREATE OR REPLACE TYPE t_phones_array AS ARRAY(100) OF T_PHONE
|
1005
1018
|
SQL
|
1006
|
-
plsql.
|
1019
|
+
plsql.execute <<-SQL
|
1007
1020
|
CREATE OR REPLACE FUNCTION test_copy_objects(p_phones IN t_phones_array, x_phones OUT t_phones_array)
|
1008
1021
|
RETURN t_phones_array
|
1009
1022
|
IS
|
@@ -1015,14 +1028,14 @@ describe "Parameter type mapping /" do
|
|
1015
1028
|
end
|
1016
1029
|
|
1017
1030
|
after(:all) do
|
1018
|
-
plsql.
|
1019
|
-
plsql.
|
1020
|
-
plsql.
|
1021
|
-
plsql.
|
1022
|
-
plsql.
|
1023
|
-
plsql.
|
1024
|
-
plsql.
|
1025
|
-
plsql.
|
1031
|
+
plsql.execute "DROP FUNCTION test_sum"
|
1032
|
+
plsql.execute "DROP FUNCTION test_increment"
|
1033
|
+
plsql.execute "DROP FUNCTION test_copy_strings"
|
1034
|
+
plsql.execute "DROP FUNCTION test_copy_objects"
|
1035
|
+
plsql.execute "DROP TYPE t_numbers_array"
|
1036
|
+
plsql.execute "DROP TYPE t_strings_array"
|
1037
|
+
plsql.execute "DROP TYPE t_phones_array"
|
1038
|
+
plsql.execute "DROP TYPE t_phone"
|
1026
1039
|
end
|
1027
1040
|
|
1028
1041
|
it "should find existing function" do
|
@@ -1057,8 +1070,8 @@ describe "Parameter type mapping /" do
|
|
1057
1070
|
describe "Function with cursor return value or parameter" do
|
1058
1071
|
|
1059
1072
|
before(:all) do
|
1060
|
-
plsql.
|
1061
|
-
plsql.
|
1073
|
+
plsql.execute "DROP TABLE test_employees" rescue nil
|
1074
|
+
plsql.execute <<-SQL
|
1062
1075
|
CREATE TABLE test_employees (
|
1063
1076
|
employee_id NUMBER(15),
|
1064
1077
|
first_name VARCHAR2(50),
|
@@ -1066,7 +1079,7 @@ describe "Parameter type mapping /" do
|
|
1066
1079
|
hire_date DATE
|
1067
1080
|
)
|
1068
1081
|
SQL
|
1069
|
-
plsql.
|
1082
|
+
plsql.execute <<-SQL
|
1070
1083
|
CREATE OR REPLACE PROCEDURE test_insert_employee(p_employee test_employees%ROWTYPE)
|
1071
1084
|
IS
|
1072
1085
|
BEGIN
|
@@ -1074,7 +1087,7 @@ describe "Parameter type mapping /" do
|
|
1074
1087
|
VALUES p_employee;
|
1075
1088
|
END;
|
1076
1089
|
SQL
|
1077
|
-
plsql.
|
1090
|
+
plsql.execute <<-SQL
|
1078
1091
|
CREATE OR REPLACE FUNCTION test_cursor
|
1079
1092
|
RETURN SYS_REFCURSOR
|
1080
1093
|
IS
|
@@ -1085,7 +1098,7 @@ describe "Parameter type mapping /" do
|
|
1085
1098
|
RETURN l_cursor;
|
1086
1099
|
END;
|
1087
1100
|
SQL
|
1088
|
-
plsql.
|
1101
|
+
plsql.execute <<-SQL
|
1089
1102
|
CREATE OR REPLACE PROCEDURE test_cursor_out(x_cursor OUT SYS_REFCURSOR)
|
1090
1103
|
IS
|
1091
1104
|
BEGIN
|
@@ -1093,7 +1106,7 @@ describe "Parameter type mapping /" do
|
|
1093
1106
|
SELECT * FROM test_employees ORDER BY employee_id;
|
1094
1107
|
END;
|
1095
1108
|
SQL
|
1096
|
-
plsql.
|
1109
|
+
plsql.execute <<-SQL
|
1097
1110
|
CREATE OR REPLACE FUNCTION test_cursor_fetch(p_cursor SYS_REFCURSOR)
|
1098
1111
|
RETURN test_employees%ROWTYPE
|
1099
1112
|
IS
|
@@ -1119,11 +1132,11 @@ describe "Parameter type mapping /" do
|
|
1119
1132
|
end
|
1120
1133
|
|
1121
1134
|
after(:all) do
|
1122
|
-
plsql.
|
1123
|
-
plsql.
|
1124
|
-
plsql.
|
1125
|
-
plsql.
|
1126
|
-
plsql.
|
1135
|
+
plsql.execute "DROP FUNCTION test_cursor"
|
1136
|
+
plsql.execute "DROP PROCEDURE test_cursor_out"
|
1137
|
+
plsql.execute "DROP PROCEDURE test_insert_employee"
|
1138
|
+
plsql.execute "DROP FUNCTION test_cursor_fetch"
|
1139
|
+
plsql.execute "DROP TABLE test_employees"
|
1127
1140
|
end
|
1128
1141
|
|
1129
1142
|
it "should find existing function" do
|
@@ -1211,7 +1224,7 @@ describe "Synonyms /" do
|
|
1211
1224
|
describe "Local synonym to function" do
|
1212
1225
|
|
1213
1226
|
before(:all) do
|
1214
|
-
plsql.
|
1227
|
+
plsql.execute <<-SQL
|
1215
1228
|
CREATE OR REPLACE FUNCTION hr.test_uppercase
|
1216
1229
|
( p_string VARCHAR2 )
|
1217
1230
|
RETURN VARCHAR2
|
@@ -1219,13 +1232,13 @@ describe "Synonyms /" do
|
|
1219
1232
|
BEGIN
|
1220
1233
|
RETURN UPPER(p_string);
|
1221
1234
|
END test_uppercase;
|
1222
|
-
|
1223
|
-
plsql.
|
1235
|
+
SQL
|
1236
|
+
plsql.execute "CREATE SYNONYM test_synonym FOR hr.test_uppercase"
|
1224
1237
|
end
|
1225
1238
|
|
1226
1239
|
after(:all) do
|
1227
|
-
plsql.
|
1228
|
-
plsql.
|
1240
|
+
plsql.execute "DROP SYNONYM test_synonym"
|
1241
|
+
plsql.execute "DROP FUNCTION hr.test_uppercase"
|
1229
1242
|
end
|
1230
1243
|
|
1231
1244
|
it "should find synonym to function" do
|
@@ -1241,18 +1254,18 @@ describe "Synonyms /" do
|
|
1241
1254
|
describe "Public synonym to function" do
|
1242
1255
|
|
1243
1256
|
before(:all) do
|
1244
|
-
plsql.
|
1257
|
+
plsql.execute <<-SQL
|
1245
1258
|
CREATE OR REPLACE FUNCTION hr.test_ora_login_user
|
1246
1259
|
RETURN VARCHAR2
|
1247
1260
|
IS
|
1248
1261
|
BEGIN
|
1249
1262
|
RETURN 'XXX';
|
1250
1263
|
END test_ora_login_user;
|
1251
|
-
|
1264
|
+
SQL
|
1252
1265
|
end
|
1253
1266
|
|
1254
1267
|
after(:all) do
|
1255
|
-
plsql.
|
1268
|
+
plsql.execute "DROP FUNCTION hr.test_ora_login_user"
|
1256
1269
|
end
|
1257
1270
|
|
1258
1271
|
it "should find public synonym to function" do
|
@@ -1263,13 +1276,17 @@ describe "Synonyms /" do
|
|
1263
1276
|
plsql.ora_login_user.should == 'HR'
|
1264
1277
|
end
|
1265
1278
|
|
1279
|
+
it "should not find public synonym if schema prefix is used" do
|
1280
|
+
lambda { plsql.hr.ora_login_user }.should raise_error(ArgumentError)
|
1281
|
+
end
|
1282
|
+
|
1266
1283
|
it "should find private synonym before public synonym" do
|
1267
1284
|
# should reconnect to force clearing of procedure cache
|
1268
1285
|
plsql.connection = get_connection
|
1269
|
-
plsql.
|
1270
|
-
plsql.
|
1286
|
+
plsql.execute "DROP SYNONYM ora_login_user" rescue nil
|
1287
|
+
plsql.execute "CREATE SYNONYM ora_login_user FOR hr.test_ora_login_user"
|
1271
1288
|
plsql.ora_login_user.should == 'XXX'
|
1272
|
-
plsql.
|
1289
|
+
plsql.execute "DROP SYNONYM ora_login_user"
|
1273
1290
|
plsql.connection = get_connection
|
1274
1291
|
plsql.ora_login_user.should == 'HR'
|
1275
1292
|
end
|
@@ -1277,3 +1294,19 @@ describe "Synonyms /" do
|
|
1277
1294
|
end
|
1278
1295
|
|
1279
1296
|
end
|
1297
|
+
|
1298
|
+
describe "SYS.STANDARD procedures /" do
|
1299
|
+
|
1300
|
+
before(:all) do
|
1301
|
+
plsql.connection = get_connection
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
after(:all) do
|
1305
|
+
plsql.logoff
|
1306
|
+
end
|
1307
|
+
|
1308
|
+
it "should execute function from SYS.STANDARD package" do
|
1309
|
+
plsql.upper('abc').should == 'ABC'
|
1310
|
+
end
|
1311
|
+
|
1312
|
+
end
|