ruby-plsql 0.9.9-java
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.
- checksums.yaml +7 -0
- data/History.txt +282 -0
- data/License.txt +20 -0
- data/README.md +263 -0
- data/VERSION +1 -0
- data/lib/plsql/connection.rb +230 -0
- data/lib/plsql/helpers.rb +7 -0
- data/lib/plsql/jdbc_connection.rb +588 -0
- data/lib/plsql/oci_connection.rb +324 -0
- data/lib/plsql/package.rb +87 -0
- data/lib/plsql/procedure.rb +584 -0
- data/lib/plsql/procedure_call.rb +626 -0
- data/lib/plsql/schema.rb +296 -0
- data/lib/plsql/sequence.rb +46 -0
- data/lib/plsql/sql_statements.rb +85 -0
- data/lib/plsql/table.rb +345 -0
- data/lib/plsql/type.rb +270 -0
- data/lib/plsql/variable.rb +143 -0
- data/lib/plsql/version.rb +3 -0
- data/lib/plsql/view.rb +38 -0
- data/lib/ruby-plsql.rb +1 -0
- data/lib/ruby_plsql.rb +13 -0
- metadata +120 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 18b86cab37ad4e2c065fc5d6f7a4f135e323b5a19b7936f8f7115a071822156a
|
|
4
|
+
data.tar.gz: 6e90c1f784078dd9257177779ae717ae40a60df31f9d7eb32cef0e6d5be86cd7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c42ac9fa3953777e6a1e2043892ec95b1cb3c354fce9f91fe321768172f6b3f41f2d60c900d30f81f1fd356e5806b1a21562d082d80404ff19838ac3017adc97
|
|
7
|
+
data.tar.gz: e2aee4162136e52abf6d8dc19af009c0ecd6e47792c13d9c5aff89a1cbf8d408dca5cb8eac76e9f71b56481c0361bf87d6e39fa92e52a17a96c5bf1cc9ecc346
|
data/History.txt
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
This file is no longer being updated. For the latest updates and release information, please see: https://github.com/rsim/ruby-plsql/releases
|
|
2
|
+
|
|
3
|
+
== 0.8.0 2021-08-10
|
|
4
|
+
* Improvements and fixes
|
|
5
|
+
* Support Rails 6.1 [#193]
|
|
6
|
+
* Support Rails 6.0 [#178]
|
|
7
|
+
* Support Oracle Database 18c or higher [#196]
|
|
8
|
+
* case-insensitive table names and proc params [#185]
|
|
9
|
+
* Use OCI driver type for RUBY_ENGINE TruffleRuby [#190]
|
|
10
|
+
* Replace NativeException with Java::JavaSql::SQLException [#192]
|
|
11
|
+
* Fixnum and Bignum are deprecated in Ruby 2.4 [#191]
|
|
12
|
+
|
|
13
|
+
* CI
|
|
14
|
+
* Run CI with GitHub Actions [#198]
|
|
15
|
+
* CI against Rails 6.1 [#193]
|
|
16
|
+
* CI against Rails 6.0 [#178]
|
|
17
|
+
* CI against Ruby 3.0.2, 2.7.4 and 2.6.8 [#197]
|
|
18
|
+
* Exclude jruby-head with Rails main [#194]
|
|
19
|
+
* Exclude jruby-head with Rails main [#194]
|
|
20
|
+
* Bump RuboCop version to 0.81.0 [#186]
|
|
21
|
+
* Run RuboCop using GitHub Actions [#180, #182]
|
|
22
|
+
* Remove .codeclimate.yml [#181]
|
|
23
|
+
* Fallback to bundler 1.7.13 [#171]
|
|
24
|
+
* Terminate CI against Ruby 2.2.x [#172]
|
|
25
|
+
* Use Ubuntu Xenial at Travis CI [#176]
|
|
26
|
+
|
|
27
|
+
== 0.7.1 2018-09-03
|
|
28
|
+
* Fix
|
|
29
|
+
* Address incorrect versions in Gemfile
|
|
30
|
+
|
|
31
|
+
== 0.7.0 2018-09-03
|
|
32
|
+
* Improvements and fixes
|
|
33
|
+
|
|
34
|
+
* Support Rails 5.0, 5.1 and 5.2
|
|
35
|
+
* Drop Rails 4.1 and 4.2 support
|
|
36
|
+
* Drop JRuby 1.7 support
|
|
37
|
+
* Drop JRuby 9.0 support
|
|
38
|
+
* Drop CRuby 2.1 or lower support
|
|
39
|
+
* Allow calling procedures in INVALID status
|
|
40
|
+
* Bignum, Fixnum, Integer fixes for Ruby 2.4
|
|
41
|
+
* Replace deprecated BigDecimal.new() with BigDecimal()
|
|
42
|
+
* Suppress warning `BigDecimal.new` is deprecated
|
|
43
|
+
* Avoid using `OCI8#describe_synonym`
|
|
44
|
+
* Allow ojdbc7.jar when Java version is 1.7 or higher
|
|
45
|
+
* Fix unguarded OCIError (breaks on JRuby)
|
|
46
|
+
* Suppress `warning: instance variable @dbms_output_stream not initialized`
|
|
47
|
+
* Suppress `warning: assigned but unused variable`
|
|
48
|
+
* Suppress `warning: shadowing outer local variable - column`
|
|
49
|
+
* Add license to gemspec
|
|
50
|
+
* Migrate from jeweler to juwelier
|
|
51
|
+
* CI against JRuby 9.1.8 and CRuby 2.4 and 2.5
|
|
52
|
+
* CI against jruby-head and ruby-head
|
|
53
|
+
* Enable RuboCop
|
|
54
|
+
* Set `disk_asynch_io` to `false`
|
|
55
|
+
* Skip XMLType specs if Oracle Database version is 12c or higher
|
|
56
|
+
|
|
57
|
+
== 0.6.0 2016-03-13
|
|
58
|
+
* Improvements
|
|
59
|
+
* Add support for records with boolean attributes - as input and output parameters and as return values of stored procedures
|
|
60
|
+
* Add support for VARCHAR, SIMPLE_INTEGER+subtypes
|
|
61
|
+
* Accessing to package objects via #[]
|
|
62
|
+
* Add XMLTYPE support for procedures and functions
|
|
63
|
+
* New procedure argument metadata option 'defaulted'
|
|
64
|
+
* Use current_schema in PLSQL::Schema#schema_name
|
|
65
|
+
* Add support for ruby-oci8 ~> 2.1 (was ~> 2.1.2) - as ruby-oci8 2.2.x is already available
|
|
66
|
+
* Add support for Oracle enhanced adapter 1.6.x
|
|
67
|
+
* Bug fixes
|
|
68
|
+
* Time-zone configuration support fixes and improvements. Support for Session timezone from ENV['TZ'] removed
|
|
69
|
+
* Fix thread safety problem in PLSQL::OCIConnection::Cursor
|
|
70
|
+
* Fix: JRuby PLS_INTEGER, BINARY_INTEGER NULL value becomes 0
|
|
71
|
+
* Internal (development) improvements
|
|
72
|
+
* Travis CI setup for the project
|
|
73
|
+
* Allow reporting of Unit Tests on Jenkins CI with "RspecJunitFormatter"
|
|
74
|
+
* Vagrant box CentOS version updated to v7.2
|
|
75
|
+
* Unit tests setup/teardown fixes for procedure_spec
|
|
76
|
+
* Documentation
|
|
77
|
+
* Add reference to ruby-plsql cheat sheet
|
|
78
|
+
|
|
79
|
+
== 0.5.3 2015-05-07
|
|
80
|
+
|
|
81
|
+
* Improvements
|
|
82
|
+
* Support for ActiveRecord 4.2
|
|
83
|
+
* Docs
|
|
84
|
+
* README formatting fixed (Usage with Rails section)
|
|
85
|
+
* Bug fixes
|
|
86
|
+
* Force to convert String type value as real string to avoid error when used JRuby and for VARCHAR2 parameter is assigned non String value
|
|
87
|
+
* Fix dbms_output functionality in case when database exception is raised
|
|
88
|
+
* Internal (development) improvements
|
|
89
|
+
* Vagrant box provisioning added
|
|
90
|
+
|
|
91
|
+
== 0.5.2 2014-10-23
|
|
92
|
+
|
|
93
|
+
* Bug fixes
|
|
94
|
+
* Use all_procedures.object_type only if Oracle versions < 11g (regression in 0.5.1, affecting Oracle < 11g)
|
|
95
|
+
|
|
96
|
+
== 0.5.1 2014-10-12
|
|
97
|
+
|
|
98
|
+
* Improvements
|
|
99
|
+
* Support for Oracle Ehnanced Adapter 1.5 and ActiveRecord 4.1, 4.2
|
|
100
|
+
* Oracle 12c support
|
|
101
|
+
* Better diagnostics output when ruby-oci8 initialization fails
|
|
102
|
+
* Bug fixes
|
|
103
|
+
* Support for ruby-oci8 2.1.2+ preventing segfaults
|
|
104
|
+
* Multi-thread support (applies to oci8 connections)
|
|
105
|
+
* Internal (development) improvements
|
|
106
|
+
* Tests database connection enhancements (eazy connect syntax, allow service name != db name)
|
|
107
|
+
* Tests migrated to rspec 3
|
|
108
|
+
* Tests coverage migrated from rcov to simplecov
|
|
109
|
+
* README update with how to run tests
|
|
110
|
+
|
|
111
|
+
== 0.5.0 2012-04-16
|
|
112
|
+
|
|
113
|
+
* Improvements
|
|
114
|
+
* Support for ruby-oci8 2.1.0 and ActiveRecord 3.2
|
|
115
|
+
* Tested with Ruby 1.9.3
|
|
116
|
+
* Tests migrated to RSpec 2
|
|
117
|
+
* Use ojdbc6.jar or ojdbc5.jar JDBC drivers when using JRuby
|
|
118
|
+
* Bug fixes
|
|
119
|
+
* Fixed clearing of global temp tables before procedure calls
|
|
120
|
+
* Fixed passing NULL value for CLOB type arguments
|
|
121
|
+
* Fixed procedure call that returns array of records
|
|
122
|
+
* Fixed support for NCHAR and NVARCHAR argument types
|
|
123
|
+
* Accept any ActiveRecord inherited model class for activerecord_class= method
|
|
124
|
+
|
|
125
|
+
== 0.4.4 2010-10-06
|
|
126
|
+
|
|
127
|
+
* Improvements
|
|
128
|
+
* When using plsql.connect! then set session time zone from ENV['TZ'] or from :time_zone option
|
|
129
|
+
* Bug fixes
|
|
130
|
+
* Bugfix for case when object is in invalid state but has no errors
|
|
131
|
+
* Support ref cursor return value with type defined inside package
|
|
132
|
+
|
|
133
|
+
== 0.4.3 2010-03-25
|
|
134
|
+
|
|
135
|
+
* Improvements
|
|
136
|
+
* plsql.connection.database_version will return also update and patch components of version number
|
|
137
|
+
* :column => :is_null and :column => :is_not_null conditions in table select operations
|
|
138
|
+
* Bug fixes
|
|
139
|
+
* Bugfix for calling procedure with table of records type (defined inside package) output parameter
|
|
140
|
+
* Use subprogram_id column in all_arguments view only if database version is >= 10.2.0.2
|
|
141
|
+
* Support partial list of named arguments for overloaded procedures (assuming that missing arguments will have default value)
|
|
142
|
+
|
|
143
|
+
== 0.4.2 2010-02-26
|
|
144
|
+
|
|
145
|
+
* New features
|
|
146
|
+
* Support default and custom constructors of object types, support member and static method calls on PL/SQL objects
|
|
147
|
+
* Support for PL/SQL record types defined inside packages
|
|
148
|
+
* Support for PL/SQL table and index-by table of records types defined inside packages
|
|
149
|
+
* plsql.savepoint and plsql.rollback_to methods
|
|
150
|
+
* plsql.connect! method for establishing new connection
|
|
151
|
+
* Improvements
|
|
152
|
+
* Better support for detecting matching overloaded implementation of procedure by sequential argument types
|
|
153
|
+
* Check if database object is valid and raise exception with compilation error if not valid
|
|
154
|
+
* Store :nullable and :data_default in table and view columns metadata
|
|
155
|
+
* Bug fixes
|
|
156
|
+
* accessing package variables with schema prefixed object types
|
|
157
|
+
* insert of TIMESTAMP values in table
|
|
158
|
+
* support package variables with VARCHAR2(n CHAR) and VARCHAR2(n BYTE) types
|
|
159
|
+
* table select :order_by option
|
|
160
|
+
|
|
161
|
+
== 0.4.1 2010-01-04
|
|
162
|
+
|
|
163
|
+
* New features
|
|
164
|
+
* Call procedures from SYS.STANDARD without schema and package prefix
|
|
165
|
+
* DBMS_OUTPUT logging to specified IO stream (e.g. plsql.dbms_output_stream = STDOUT)
|
|
166
|
+
* Support table operations also on views
|
|
167
|
+
* Specify plsql.connection.prefetch_rows= to reduce network round trips when selecting large number of rows
|
|
168
|
+
* Support for PLS_INTEGER and BINARY_INTEGER parameters and return values
|
|
169
|
+
* Access to package variables (basic types, object types, %TYPE and %ROWTYPE)
|
|
170
|
+
* Table insert_values method
|
|
171
|
+
* Insert partial list of table column values (and use default values for missing columns)
|
|
172
|
+
* Improvements
|
|
173
|
+
* Improved performance of table and synonyms metadata select
|
|
174
|
+
* Check required ruby-oci8 version
|
|
175
|
+
* Bug fixes
|
|
176
|
+
* limit object types when selecting from all_objects to avoid getting irrelevant records with the same name
|
|
177
|
+
* select where condition :column => nil is transformed to "column IS NULL"
|
|
178
|
+
* TIMESTAMP fractional seconds patch for ruby-oci8 2.0.3
|
|
179
|
+
|
|
180
|
+
== 0.4.0 2009-11-23
|
|
181
|
+
|
|
182
|
+
* New features
|
|
183
|
+
* Support for PL/SQL RECORD, BOOLEAN, TABLE, VARRAY, OBJECT and CURSOR parameters and return values
|
|
184
|
+
* Support for basic table and sequence operations
|
|
185
|
+
* A lot of refactoring
|
|
186
|
+
|
|
187
|
+
== 0.3.1 2009-06-05
|
|
188
|
+
|
|
189
|
+
* Bug fixes
|
|
190
|
+
* fixed usage of plsql.activerecord_class = ... (fixes OCIInvalidHandle exception in development mode with ActiveRecord 2.2+)
|
|
191
|
+
|
|
192
|
+
== 0.3.0 2009-04-21
|
|
193
|
+
|
|
194
|
+
* New features
|
|
195
|
+
* Added Ruby 1.9.1 and ruby-oci8 2.x support
|
|
196
|
+
* Use plsql.activerecord_class = ActiveRecord::Base to simplify usage with Rails
|
|
197
|
+
* Improvements
|
|
198
|
+
* DATE to Time and DateTime conversion according to plsql.default_timezone (:local or :utc)
|
|
199
|
+
Use ActiveRecord::Base.default_timezone if plsql.activerecord_class=... is used
|
|
200
|
+
* Added BLOB data type support for input and output parameters and function return values
|
|
201
|
+
* Added support for private and public synonyms to functions/procedures and packages
|
|
202
|
+
|
|
203
|
+
== 0.2.4 2009-03-06
|
|
204
|
+
|
|
205
|
+
* Bug fixes
|
|
206
|
+
* Fixed that procedures can be called with VARCHAR2 parameters with length up to 32767
|
|
207
|
+
|
|
208
|
+
== 0.2.3 2008-10-17
|
|
209
|
+
|
|
210
|
+
* Improvements
|
|
211
|
+
* Added CLOB data type support for input and output parameters and function return values
|
|
212
|
+
(both for MRI/OCI and JRuby/JDBC)
|
|
213
|
+
(ruby-oci8 version should be at least 1.0.3 as it contains CLOB handling bug fixes)
|
|
214
|
+
* Bug fixes
|
|
215
|
+
* Fixed calling of procedures without parameters
|
|
216
|
+
|
|
217
|
+
== 0.2.2 2008-08-20
|
|
218
|
+
* Bug fixes
|
|
219
|
+
* Workaround for strange Oracle data dictionary bug when procedure with no parameters has row with empty fields in all_arguments
|
|
220
|
+
|
|
221
|
+
== 0.2.1 2008-07-22
|
|
222
|
+
|
|
223
|
+
* Improvements
|
|
224
|
+
* Implemented plsql.commit and plsql.rollback methods which call corresponding Connection methods.
|
|
225
|
+
In addition plsql.connection.autocommit= and plsql.connection.autocommit? methods are added.
|
|
226
|
+
* Bug fixes
|
|
227
|
+
* Fixed loading of ojdbc14.jar from PATH directory
|
|
228
|
+
* Workaround for slow SELECT from all_arguments in Oracle 10gR2
|
|
229
|
+
|
|
230
|
+
== 0.2.0 2008-06-26
|
|
231
|
+
|
|
232
|
+
* New features
|
|
233
|
+
* Added JRuby and Oracle JDBC driver support with the same functionality as in case of MRI and ruby-oci8 driver
|
|
234
|
+
* All database driver specifics are extracted in separate Connection class with OCIConnection and JDBCConnection subclasses
|
|
235
|
+
* Improvements
|
|
236
|
+
* PL/SQL functions/procedures with DATE return values and output parameters returns Time values by default (previously DateTime values
|
|
237
|
+
were returned by default). If value is too old then DateTime value is returned. From Ruby Time, DateTime and Date values can be
|
|
238
|
+
passed as arguments to DATE parameters.
|
|
239
|
+
|
|
240
|
+
== 0.1.6 2008-06-16
|
|
241
|
+
|
|
242
|
+
* Improvements
|
|
243
|
+
* If PL/SQL functions with output parameters are called then the result will be array with the function return value as a first element
|
|
244
|
+
and a hash with output parameters values as a second element.
|
|
245
|
+
|
|
246
|
+
== 0.1.5 2008-06-13
|
|
247
|
+
|
|
248
|
+
* Bug fixes
|
|
249
|
+
* Fixed bug when ruby-plsql was not finding packages on Oracle 10.2 Enterprise Edition where all_procedures view
|
|
250
|
+
behaves differently than on Oracle XE and other previous versions
|
|
251
|
+
|
|
252
|
+
== 0.1.4 2008-04-18
|
|
253
|
+
|
|
254
|
+
* Bug fixes
|
|
255
|
+
* Fixed bug when nil numeric parameters where passed as 0, now nil numeric parameter is passed as NULL
|
|
256
|
+
|
|
257
|
+
== 0.1.3 2008-04-15
|
|
258
|
+
|
|
259
|
+
* Improvements
|
|
260
|
+
* Support for overloaded procedure definitions (named parameter calls compared by number of arguments and by argument names,
|
|
261
|
+
sequential parameters compared by number of arguments)
|
|
262
|
+
* Bug fixes
|
|
263
|
+
* Fixed BigDecimal support for procedure parameters (all number types except from Fixnum are converted to Float)
|
|
264
|
+
* Fixed Date parameters support (always will convert to DateTime)
|
|
265
|
+
|
|
266
|
+
== 0.1.2 2008-04-02
|
|
267
|
+
|
|
268
|
+
* Improvements
|
|
269
|
+
* When PL/SQL procedure is called with less arguments then missing arguments are filled with nil
|
|
270
|
+
|
|
271
|
+
== 0.1.1 2008-04-01
|
|
272
|
+
|
|
273
|
+
* Bug fixes
|
|
274
|
+
* Improved performance of PL/SQL procedure arguments selection in large databases
|
|
275
|
+
* Added schema and package names in generated PL/SQL block when calling procedures from packages
|
|
276
|
+
|
|
277
|
+
== 0.1.0 2008-03-15
|
|
278
|
+
|
|
279
|
+
* Initial release
|
|
280
|
+
* Known limitations
|
|
281
|
+
* Currently just NUMBER, VARCHAR2, DATE, TIMESTAMP argument types are supported for PL/SQL procedures
|
|
282
|
+
|
data/License.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008-2012 Raimonds Simanovskis
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
[](https://github.com/rsim/ruby-plsql/actions/workflows/test.yml)
|
|
2
|
+
|
|
3
|
+
ruby-plsql
|
|
4
|
+
==========
|
|
5
|
+
|
|
6
|
+
Ruby API for calling Oracle PL/SQL procedures.
|
|
7
|
+
|
|
8
|
+
DESCRIPTION
|
|
9
|
+
-----------
|
|
10
|
+
|
|
11
|
+
ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures. It could be used both for accessing Oracle PL/SQL API procedures in legacy applications as well as it could be used to create PL/SQL unit tests using Ruby testing libraries.
|
|
12
|
+
|
|
13
|
+
NUMBER, BINARY_INTEGER, PLS_INTEGER, NATURAL, NATURALN, POSITIVE, POSITIVEN, SIGNTYPE, SIMPLE_INTEGER, VARCHAR, VARCHAR2, NVARCHAR2, CHAR, NCHAR, DATE, TIMESTAMP, CLOB, BLOB, BOOLEAN, PL/SQL RECORD, TABLE, VARRAY, OBJECT and CURSOR types are supported for input and output parameters and return values of PL/SQL procedures and functions.
|
|
14
|
+
|
|
15
|
+
ruby-plsql supports Ruby 2.2, 2.3, 2.4, 2.5 (ruby-oci8 2.2.3+ is needed for Ruby 2.4) and JRuby 9.1 implementations.
|
|
16
|
+
|
|
17
|
+
USAGE
|
|
18
|
+
-----
|
|
19
|
+
|
|
20
|
+
### Calling PL/SQL functions and procedures:
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
require "rubygems"
|
|
24
|
+
require "ruby-plsql"
|
|
25
|
+
|
|
26
|
+
plsql.connection = OCI8.new("hr","hr","xe")
|
|
27
|
+
|
|
28
|
+
plsql.test_uppercase('xxx') # => "XXX"
|
|
29
|
+
plsql.test_uppercase(:p_string => 'xxx') # => "XXX"
|
|
30
|
+
plsql.test_copy("abc", nil, nil) # => { :p_to => "abc", :p_to_double => "abcabc" }
|
|
31
|
+
plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil)
|
|
32
|
+
# => { :p_to => "abc", :p_to_double => "abcabc" }
|
|
33
|
+
plsql.hr.test_uppercase('xxx') # => "XXX"
|
|
34
|
+
plsql.test_package.test_uppercase('xxx') # => 'XXX'
|
|
35
|
+
|
|
36
|
+
# PL/SQL records or object type parameters should be passed as Hash
|
|
37
|
+
p_employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31) }
|
|
38
|
+
plsql.test_full_name(p_employee)
|
|
39
|
+
|
|
40
|
+
# TABLE or VARRAY parameters should be passed as Array
|
|
41
|
+
plsql.test_sum([1,2,3,4])
|
|
42
|
+
|
|
43
|
+
# Nested objects or arrays are also supported
|
|
44
|
+
p_employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31),
|
|
45
|
+
:address => {:street => 'Street', :city => 'City', :country => 'Country'},
|
|
46
|
+
:phones => [{:type => 'mobile', :phone_number => '123456'}, {:type => 'fixed', :phone_number => '654321'}]}
|
|
47
|
+
plsql.test_store_employee(p_employee)
|
|
48
|
+
|
|
49
|
+
# Returned cursor can be fetched
|
|
50
|
+
plsql.test_cursor do |cursor|
|
|
51
|
+
cursor.fetch # => one row from cursor
|
|
52
|
+
cursor.fetch_all # => all rows from cursor
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
plsql.connection.autocommit = false
|
|
56
|
+
plsql.commit
|
|
57
|
+
plsql.rollback
|
|
58
|
+
|
|
59
|
+
plsql.logoff
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Look at RSpec tests under spec directory for more usage examples.
|
|
63
|
+
|
|
64
|
+
Note: named arguments in procedures calls should be in lower case.
|
|
65
|
+
|
|
66
|
+
### Table operations:
|
|
67
|
+
|
|
68
|
+
ruby-plsql also provides simple API for select/insert/update/delete table operations (with Sequel-like syntax). This could be useful if ruby-plsql is used without ActiveRecord (e.g. for writing PL/SQL unit tests):
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
# insert record in table
|
|
72
|
+
employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31) }
|
|
73
|
+
plsql.employees.insert employee # INSERT INTO employees VALUES (1, 'First', 'Last', ...)
|
|
74
|
+
|
|
75
|
+
# insert many records
|
|
76
|
+
employees = [employee1, employee2, ... ] # array of many Hashes
|
|
77
|
+
plsql.employees.insert employees
|
|
78
|
+
|
|
79
|
+
# insert many records as list of values
|
|
80
|
+
plsql.employees.insert_values [:employee_id, :first_name, :last_name],
|
|
81
|
+
[1, 'First 1', 'Last 1'],
|
|
82
|
+
[2, 'First 2', 'Last 2']
|
|
83
|
+
|
|
84
|
+
# select one record
|
|
85
|
+
plsql.employees.first # SELECT * FROM employees
|
|
86
|
+
# fetch first row => {:employee_id => ..., :first_name => '...', ...}
|
|
87
|
+
plsql.employees.first(:employee_id => 1) # SELECT * FROM employees WHERE employee_id = 1
|
|
88
|
+
plsql.employees.first("WHERE employee_id = 1")
|
|
89
|
+
plsql.employees.first("WHERE employee_id = :employee_id", 1)
|
|
90
|
+
|
|
91
|
+
# select many records
|
|
92
|
+
plsql.employees.all # => [{...}, {...}, ...]
|
|
93
|
+
plsql.employees.all(:order_by => :employee_id)
|
|
94
|
+
plsql.employees.all("WHERE employee_id > :employee_id", 5)
|
|
95
|
+
|
|
96
|
+
# count records
|
|
97
|
+
plsql.employees.count # SELECT COUNT(*) FROM employees
|
|
98
|
+
plsql.employees.count("WHERE employee_id > :employee_id", 5)
|
|
99
|
+
|
|
100
|
+
# update records
|
|
101
|
+
plsql.employees.update(:first_name => 'Second', :where => {:employee_id => 1})
|
|
102
|
+
# UPDATE employees SET first_name = 'Second' WHERE employee_id = 1
|
|
103
|
+
|
|
104
|
+
# delete records
|
|
105
|
+
plsql.employees.delete(:employee_id => 1) # DELETE FROM employees WHERE employee_id = 1
|
|
106
|
+
|
|
107
|
+
# select from sequences
|
|
108
|
+
plsql.employees_seq.nextval # SELECT employees_seq.NEXTVAL FROM dual
|
|
109
|
+
plsql.employees_seq.currval # SELECT employees_seq.CURRVAL FROM dual
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Usage with Rails:
|
|
113
|
+
|
|
114
|
+
If using with Rails then include in initializer file:
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
plsql.activerecord_class = ActiveRecord::Base
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
and then you do not need to specify plsql.connection (this is also safer when ActiveRecord reestablishes connection to database).
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
### JRuby JDBC connection:
|
|
124
|
+
|
|
125
|
+
When using JRuby, the `connect!` method with `:host` and `:database` options uses the thin-style service name syntax by default:
|
|
126
|
+
|
|
127
|
+
```ruby
|
|
128
|
+
# Connects using service name syntax: jdbc:oracle:thin:@//localhost:1521/MYSERVICENAME
|
|
129
|
+
plsql.connect! username: "hr", password: "hr", host: "localhost", database: "MYSERVICENAME"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
If you need to connect using the legacy SID syntax (for Oracle databases older than 12c), prefix the database name with a colon:
|
|
133
|
+
|
|
134
|
+
```ruby
|
|
135
|
+
# Connects using SID syntax: jdbc:oracle:thin:@localhost:1521:MYSID
|
|
136
|
+
plsql.connect! username: "hr", password: "hr", host: "localhost", database: ":MYSID"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Cheat Sheet:
|
|
140
|
+
|
|
141
|
+
You may have a look at this [Cheat Sheet](http://cheatography.com/jgebal/cheat-sheets/ruby-plsql-cheat-sheet/) for instructions on how to use ruby-plsql
|
|
142
|
+
|
|
143
|
+
INSTALLATION
|
|
144
|
+
------------
|
|
145
|
+
|
|
146
|
+
Install as gem with
|
|
147
|
+
|
|
148
|
+
gem install ruby-plsql
|
|
149
|
+
|
|
150
|
+
or include gem in Gemfile if using bundler.
|
|
151
|
+
|
|
152
|
+
In addition install either ruby-oci8 (for MRI/YARV) or copy Oracle JDBC driver to $JRUBY_HOME/lib (for JRuby).
|
|
153
|
+
|
|
154
|
+
If you are using MRI Ruby implementation then you need to install ruby-oci8 gem (version 2.1 or higher)
|
|
155
|
+
as well as Oracle client, e.g. [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html).
|
|
156
|
+
|
|
157
|
+
If you are using JRuby then you need to download the appropriate [Oracle JDBC driver](https://www.oracle.com/database/technologies/appdev/jdbc-downloads.html) for your Java version - ojdbc17.jar for Java 17+, ojdbc11.jar for Java 11+, ojdbc8.jar for Java 8+, ojdbc7.jar for Java 7, ojdbc6.jar for Java 6, or ojdbc5.jar for Java 5.
|
|
158
|
+
|
|
159
|
+
And copy this file to one of these locations. JDBC driver will be searched in this order:
|
|
160
|
+
|
|
161
|
+
* in `JRUBY_HOME/lib` directory
|
|
162
|
+
* in `./lib` directory of Rails application
|
|
163
|
+
* or include path to JDBC driver jar file in Java `CLASSPATH`
|
|
164
|
+
* in some directory which is in `PATH`
|
|
165
|
+
|
|
166
|
+
If you put multiple versions of JDBC driver in the same directory the higher version one will be used.
|
|
167
|
+
|
|
168
|
+
Make sure to setup the following Oracle-specific environment variables properly
|
|
169
|
+
|
|
170
|
+
* [NLS_LANG](http://www.orafaq.com/wiki/NLS_LANG) - preferred value `NLS_LANG=AMERICAN_AMERICA.AL32UTF8`
|
|
171
|
+
* [ORA_SDTZ](http://docs.oracle.com/cd/E18283_01/server.112/e10729/ch4datetime.htm#CBBEEAFB) The setting should point a machine timezone like: `ORA_SDTZ=Europe/Riga`, otherwise Oracle by default uses a Fixed-offset timezone (like `03:00`) that is not daylight saving (DST) aware, which will lead to wrong translations of the timestamp values between Ruby code (DTS-aware) and Oracle session (non-DST-aware).
|
|
172
|
+
* [ORACLE_HOME](http://www.orafaq.com/wiki/ORACLE_HOME)
|
|
173
|
+
|
|
174
|
+
You may either alter your environment settings or set the values in file `spec/support/custom_config.rb`. Sample file `custom_config.rb.sample` shows how to do that.
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
Make sure you use correct version of Oracle client for database you're connecting to. Otherwise you may encounter TimeZone errors like [this](http://stackoverflow.com/questions/7678485/oracle-ora-01805-on-oracle-11g-database)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
TESTS
|
|
181
|
+
-----
|
|
182
|
+
|
|
183
|
+
Review `spec/spec_helper.rb` to see default schema/user names and database names (use environment variables to override defaults)
|
|
184
|
+
|
|
185
|
+
##### Prepare database
|
|
186
|
+
|
|
187
|
+
* With local [Vagrant](https://www.vagrantup.com) based Oracle XE database.
|
|
188
|
+
|
|
189
|
+
Download Oracle XE database ```oracle-xe-11.2.0-1.0.x86_64.rpm.zip``` from [Oracle Home page](http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html) and put it into project home directory.
|
|
190
|
+
|
|
191
|
+
From project home directory run ```vagrant up``` command to build fully functioning **Centos 6.6** virtual machine with installed Oracle XE database.
|
|
192
|
+
|
|
193
|
+
* Within other Oracle Database create Oracle database schema for test purposes.
|
|
194
|
+
|
|
195
|
+
SQL> CREATE USER hr IDENTIFIED BY hr;
|
|
196
|
+
SQL> GRANT unlimited tablespace, create session, create table, create sequence, create procedure, create type, create view, create synonym TO hr;
|
|
197
|
+
|
|
198
|
+
SQL> CREATE USER arunit IDENTIFIED BY arunit;
|
|
199
|
+
SQL> GRANT create session TO arunit;
|
|
200
|
+
|
|
201
|
+
##### Prepare dependencies
|
|
202
|
+
|
|
203
|
+
* Install bundler with
|
|
204
|
+
|
|
205
|
+
gem install bundler
|
|
206
|
+
|
|
207
|
+
* Install necessary gems with
|
|
208
|
+
|
|
209
|
+
bundle install
|
|
210
|
+
|
|
211
|
+
##### Run tests
|
|
212
|
+
|
|
213
|
+
* Run tests with local Vagrant based Oracle XE database
|
|
214
|
+
|
|
215
|
+
USE_VM_DATABASE=Y rake spec
|
|
216
|
+
|
|
217
|
+
* Run tests with other Oracle database
|
|
218
|
+
|
|
219
|
+
rake spec
|
|
220
|
+
|
|
221
|
+
LINKS
|
|
222
|
+
-----
|
|
223
|
+
|
|
224
|
+
* Source code: http://github.com/rsim/ruby-plsql
|
|
225
|
+
* Bug reports / Feature requests: http://github.com/rsim/ruby-plsql/issues
|
|
226
|
+
* Discuss at oracle_enhanced adapter group: http://groups.google.com/group/oracle-enhanced
|
|
227
|
+
|
|
228
|
+
CONTRIBUTORS
|
|
229
|
+
------------
|
|
230
|
+
|
|
231
|
+
* Raimonds Simanovskis
|
|
232
|
+
* Edgars Beigarts
|
|
233
|
+
* Oleh Mykytyuk
|
|
234
|
+
* Wiehann Matthysen
|
|
235
|
+
* Dayle Larson
|
|
236
|
+
* Yasuo Honda
|
|
237
|
+
* Yavor Nikolov
|
|
238
|
+
|
|
239
|
+
LICENSE
|
|
240
|
+
-------
|
|
241
|
+
|
|
242
|
+
(The MIT License)
|
|
243
|
+
|
|
244
|
+
Copyright (c) 2008-2014 Raimonds Simanovskis
|
|
245
|
+
|
|
246
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
247
|
+
a copy of this software and associated documentation files (the
|
|
248
|
+
'Software'), to deal in the Software without restriction, including
|
|
249
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
250
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
251
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
252
|
+
the following conditions:
|
|
253
|
+
|
|
254
|
+
The above copyright notice and this permission notice shall be
|
|
255
|
+
included in all copies or substantial portions of the Software.
|
|
256
|
+
|
|
257
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
258
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
259
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
260
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
261
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
262
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
263
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.9.9
|