flash-gordons-ruby-plsql 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZWVmNjUzYjRiN2QzZDMyNTNkN2Q4MGQ0MmE1OTNlZGM0ZjQ1NzYzNQ==
5
+ data.tar.gz: !binary |-
6
+ OTNmMzEwMzI5MDg5ZDRjNDNjZjBlMTQ5MzUxMDAxYWYxZDlkMTk5Zg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MzEzYjk3NTFhZGRhYjI4OTkwYTA4YjAzZjg0OTcyZTNmY2E0NzViODEzOWI5
10
+ OThlMjIzYTZjMzRlMzMyMWFiZDkyZjkyNGNiNDk2Yjg2ZDkwMjczZTliYjA5
11
+ MDYyZTBjZDk2NzU1NjRjODA3MDdiOTQ5MWFlYTE2ZThkZjQ2Yzg=
12
+ data.tar.gz: !binary |-
13
+ ZWMyMjY5NzAzNjBjYjczYTFhNDNkNjFkYzhlMmI2ZmY3ZDNlNTYwMDMyZGQ5
14
+ ZDhjOWFjNDQxZWZhMzM5ODAxNzg3OGY2NDIzMDA3OWU4OThjM2JlZTQ1OTQ3
15
+ MjlmMWNkYjczZWQ4NGFhNWEzNTRjYzJkYzAzOWJjODdjYTQyNDE=
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'jeweler', '~> 1.8.3'
5
+ gem 'rspec', '~> 2.9'
6
+
7
+ unless ENV['NO_ACTIVERECORD']
8
+ gem 'activerecord', '~> 3.2.3'
9
+ gem 'activerecord-oracle_enhanced-adapter', '~> 1.4.1'
10
+ end
11
+
12
+ # gem 'ruby-oci8', '~> 2.1.0'
13
+ gem 'ruby-oci8', :git => 'git://github.com/kubo/ruby-oci8.git', :platforms => :mri
14
+ end
@@ -0,0 +1,172 @@
1
+ == 0.5.0 2012-04-16
2
+
3
+ * Improvements
4
+ * Support for ruby-oci8 2.1.0 and ActiveRecord 3.2
5
+ * Tested with Ruby 1.9.3
6
+ * Tests migrated to RSpec 2
7
+ * Use ojdbc6.jar or ojdbc5.jar JDBC drivers when using JRuby
8
+ * Bug fixes
9
+ * Fixed clearing of global temp tables before procedure calls
10
+ * Fixed passing NULL value for CLOB type arguments
11
+ * Fixed procedure call that returns array of records
12
+ * Fixed support for NCHAR and NVARCHAR argument types
13
+ * Accept any ActiveRecord inherited model class for activerecord_class= method
14
+
15
+ == 0.4.4 2010-10-06
16
+
17
+ * Improvements
18
+ * When using plsql.connect! then set session time zone from ENV['TZ'] or from :time_zone option
19
+ * Bug fixes
20
+ * Bugfix for case when object is in invalid state but has no errors
21
+ * Support ref cursor return value with type defined inside package
22
+
23
+ == 0.4.3 2010-03-25
24
+
25
+ * Improvements
26
+ * plsql.connection.database_version will return also update and patch components of version number
27
+ * :column => :is_null and :column => :is_not_null conditions in table select operations
28
+ * Bug fixes
29
+ * Bugfix for calling procedure with table of records type (defined inside package) output parameter
30
+ * Use subprogram_id column in all_arguments view only if database version is >= 10.2.0.2
31
+ * Support partial list of named arguments for overloaded procedures (assuming that missing arguments will have default value)
32
+
33
+ == 0.4.2 2010-02-26
34
+
35
+ * New features
36
+ * Support default and custom constructors of object types, support member and static method calls on PL/SQL objects
37
+ * Support for PL/SQL record types defined inside packages
38
+ * Support for PL/SQL table and index-by table of records types defined inside packages
39
+ * plsql.savepoint and plsql.rollback_to methods
40
+ * plsql.connect! method for establishing new connection
41
+ * Improvements
42
+ * Better support for detecting matching overloaded implementation of procedure by sequential argument types
43
+ * Check if database object is valid and raise exception with compilation error if not valid
44
+ * Store :nullable and :data_default in table and view columns metadata
45
+ * Bug fixes
46
+ * accessing package variables with schema prefixed object types
47
+ * insert of TIMESTAMP values in table
48
+ * support package variables with VARCHAR2(n CHAR) and VARCHAR2(n BYTE) types
49
+ * table select :order_by option
50
+
51
+ == 0.4.1 2010-01-04
52
+
53
+ * New features
54
+ * Call procedures from SYS.STANDARD without schema and package prefix
55
+ * DBMS_OUTPUT logging to specified IO stream (e.g. plsql.dbms_output_stream = STDOUT)
56
+ * Support table operations also on views
57
+ * Specify plsql.connection.prefetch_rows= to reduce network round trips when selecting large number of rows
58
+ * Support for PLS_INTEGER and BINARY_INTEGER parameters and return values
59
+ * Access to package variables (basic types, object types, %TYPE and %ROWTYPE)
60
+ * Table insert_values method
61
+ * Insert partial list of table column values (and use default values for missing columns)
62
+ * Improvements
63
+ * Improved performance of table and synonyms metadata select
64
+ * Check required ruby-oci8 version
65
+ * Bug fixes
66
+ * limit object types when selecting from all_objects to avoid getting irrelevant records with the same name
67
+ * select where condition :column => nil is transformed to "column IS NULL"
68
+ * TIMESTAMP fractional seconds patch for ruby-oci8 2.0.3
69
+
70
+ == 0.4.0 2009-11-23
71
+
72
+ * New features
73
+ * Support for PL/SQL RECORD, BOOLEAN, TABLE, VARRAY, OBJECT and CURSOR parameters and return values
74
+ * Support for basic table and sequence operations
75
+ * A lot of refactoring
76
+
77
+ == 0.3.1 2009-06-05
78
+
79
+ * Bug fixes
80
+ * fixed usage of plsql.activerecord_class = ... (fixes OCIInvalidHandle exception in development mode with ActiveRecord 2.2+)
81
+
82
+ == 0.3.0 2009-04-21
83
+
84
+ * New features
85
+ * Added Ruby 1.9.1 and ruby-oci8 2.x support
86
+ * Use plsql.activerecord_class = ActiveRecord::Base to simplify usage with Rails
87
+ * Improvements
88
+ * DATE to Time and DateTime conversion according to plsql.default_timezone (:local or :utc)
89
+ Use ActiveRecord::Base.default_timezone if plsql.activerecord_class=... is used
90
+ * Added BLOB data type support for input and output parameters and function return values
91
+ * Added support for private and public synonyms to functions/procedures and packages
92
+
93
+ == 0.2.4 2009-03-06
94
+
95
+ * Bug fixes
96
+ * Fixed that procedures can be called with VARCHAR2 parameters with length up to 32767
97
+
98
+ == 0.2.3 2008-10-17
99
+
100
+ * Improvements
101
+ * Added CLOB data type support for input and output parameters and function return values
102
+ (both for MRI/OCI and JRuby/JDBC)
103
+ (ruby-oci8 version should be at least 1.0.3 as it contains CLOB handling bug fixes)
104
+ * Bug fixes
105
+ * Fixed calling of procedures without parameters
106
+
107
+ == 0.2.2 2008-08-20
108
+ * Bug fixes
109
+ * Workaround for strange Oracle data dictionary bug when procedure with no parameters has row with empty fields in all_arguments
110
+
111
+ == 0.2.1 2008-07-22
112
+
113
+ * Improvements
114
+ * Implemented plsql.commit and plsql.rollback methods which call corresponding Connection methods.
115
+ In addition plsql.connection.autocommit= and plsql.connection.autocommit? methods are added.
116
+ * Bug fixes
117
+ * Fixed loading of ojdbc14.jar from PATH directory
118
+ * Workaround for slow SELECT from all_arguments in Oracle 10gR2
119
+
120
+ == 0.2.0 2008-06-26
121
+
122
+ * New features
123
+ * Added JRuby and Oracle JDBC driver support with the same functionality as in case of MRI and ruby-oci8 driver
124
+ * All database driver specifics are extracted in separate Connection class with OCIConnection and JDBCConnection subclasses
125
+ * Improvements
126
+ * PL/SQL functions/procedures with DATE return values and output parameters returns Time values by default (previously DateTime values
127
+ were returned by default). If value is too old then DateTime value is returned. From Ruby Time, DateTime and Date values can be
128
+ passed as arguments to DATE parameters.
129
+
130
+ == 0.1.6 2008-06-16
131
+
132
+ * Improvements
133
+ * If PL/SQL functions with output parameters are called then the result will be array with the function return value as a first element
134
+ and a hash with output parameters values as a second element.
135
+
136
+ == 0.1.5 2008-06-13
137
+
138
+ * Bug fixes
139
+ * Fixed bug when ruby-plsql was not finding packages on Oracle 10.2 Enterprise Edition where all_procedures view
140
+ behaves differently than on Oracle XE and other previous versions
141
+
142
+ == 0.1.4 2008-04-18
143
+
144
+ * Bug fixes
145
+ * Fixed bug when nil numeric parameters where passed as 0, now nil numeric parameter is passed as NULL
146
+
147
+ == 0.1.3 2008-04-15
148
+
149
+ * Improvements
150
+ * Support for overloaded procedure definitions (named parameter calls compared by number of arguments and by argument names,
151
+ sequential parameters compared by number of arguments)
152
+ * Bug fixes
153
+ * Fixed BigDecimal support for procedure parameters (all number types except from Fixnum are converted to Float)
154
+ * Fixed Date parameters support (always will convert to DateTime)
155
+
156
+ == 0.1.2 2008-04-02
157
+
158
+ * Improvements
159
+ * When PL/SQL procedure is called with less arguments then missing arguments are filled with nil
160
+
161
+ == 0.1.1 2008-04-01
162
+
163
+ * Bug fixes
164
+ * Improved performance of PL/SQL procedure arguments selection in large databases
165
+ * Added schema and package names in generated PL/SQL block when calling procedures from packages
166
+
167
+ == 0.1.0 2008-03-15
168
+
169
+ * Initial release
170
+ * Known limitations
171
+ * Currently just NUMBER, VARCHAR2, DATE, TIMESTAMP argument types are supported for PL/SQL procedures
172
+
@@ -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.
@@ -0,0 +1,182 @@
1
+ ruby-plsql
2
+ ==========
3
+
4
+ Ruby API for calling Oracle PL/SQL procedures.
5
+
6
+ DESCRIPTION
7
+ -----------
8
+
9
+ 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.
10
+
11
+ NUMBER, BINARY_INTEGER, PLS_INTEGER, 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.
12
+
13
+ ruby-plsql supports Ruby 1.8.7, 1.9.3 and JRuby 1.6.7 implementations.
14
+
15
+ USAGE
16
+ -----
17
+
18
+ ### Calling PL/SQL functions and procedures:
19
+
20
+ ```ruby
21
+ require "rubygems"
22
+ require "ruby-plsql"
23
+
24
+ plsql.connection = OCI8.new("hr","hr","xe")
25
+
26
+ plsql.test_uppercase('xxx') # => "XXX"
27
+ plsql.test_uppercase(:p_string => 'xxx') # => "XXX"
28
+ plsql.test_copy("abc", nil, nil) # => { :p_to => "abc", :p_to_double => "abcabc" }
29
+ plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil)
30
+ # => { :p_to => "abc", :p_to_double => "abcabc" }
31
+ plsql.hr.test_uppercase('xxx') # => "XXX"
32
+ plsql.test_package.test_uppercase('xxx') # => 'XXX'
33
+
34
+ # PL/SQL records or object type parameters should be passed as Hash
35
+ p_employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31) }
36
+ plsql.test_full_name(p_employee)
37
+
38
+ # TABLE or VARRAY parameters should be passed as Array
39
+ plsql.test_sum([1,2,3,4])
40
+
41
+ # Nested objects or arrays are also supported
42
+ p_employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31),
43
+ :address => {:street => 'Street', :city => 'City', :country => 'Country'},
44
+ :phones => [{:type => 'mobile', :phone_number => '123456'}, {:type => 'fixed', :phone_number => '654321'}]}
45
+ plsql.test_store_employee(p_employee)
46
+
47
+ # Returned cursor can be fetched
48
+ plsql.test_cursor do |cursor|
49
+ cursor.fetch # => one row from cursor
50
+ cursor.fetch_all # => all rows from cursor
51
+ end
52
+
53
+ plsql.connection.autocommit = false
54
+ plsql.commit
55
+ plsql.rollback
56
+
57
+ plsql.logoff
58
+ ```
59
+
60
+ Look at RSpec tests under spec directory for more usage examples.
61
+
62
+
63
+ ### Table operations:
64
+
65
+ 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):
66
+
67
+ ```ruby
68
+ # insert record in table
69
+ employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31) }
70
+ plsql.employees.insert employee # INSERT INTO employees VALUES (1, 'First', 'Last', ...)
71
+
72
+ # insert many records
73
+ employees = [employee1, employee2, ... ] # array of many Hashes
74
+ plsql.employees.insert employees
75
+
76
+ # insert many records as list of values
77
+ plsql.employees.insert_values [:employee_id, :first_name, :last_name],
78
+ [1, 'First 1', 'Last 1'],
79
+ [2, 'First 2', 'Last 2']
80
+
81
+ # select one record
82
+ plsql.employees.first # SELECT * FROM employees
83
+ # fetch first row => {:employee_id => ..., :first_name => '...', ...}
84
+ plsql.employees.first(:employee_id => 1) # SELECT * FROM employees WHERE employee_id = 1
85
+ plsql.employees.first("WHERE employee_id = 1")
86
+ plsql.employees.first("WHERE employee_id = :employee_id", 1)
87
+
88
+ # select many records
89
+ plsql.employees.all # => [{...}, {...}, ...]
90
+ plsql.employees.all(:order_by => :employee_id)
91
+ plsql.employees.all("WHERE employee_id > :employee_id", 5)
92
+
93
+ # count records
94
+ plsql.employees.count # SELECT COUNT(*) FROM employees
95
+ plsql.employees.count("WHERE employee_id > :employee_id", 5)
96
+
97
+ # update records
98
+ plsql.employees.update(:first_name => 'Second', :where => {:employee_id => 1})
99
+ # UPDATE employees SET first_name = 'Second' WHERE employee_id = 1
100
+
101
+ # delete records
102
+ plsql.employees.delete(:employee_id => 1) # DELETE FROM employees WHERE employee_id = 1
103
+
104
+ # select from sequences
105
+ plsql.employees_seq.nextval # SELECT employees_seq.NEXTVAL FROM dual
106
+ plsql.employees_seq.currval # SELECT employees_seq.CURRVAL FROM dual
107
+
108
+
109
+ ### Usage with Rails:
110
+
111
+ If using with Rails then include in initializer file:
112
+
113
+ ```ruby
114
+ plsql.activerecord_class = ActiveRecord::Base
115
+ ```
116
+
117
+ and then you do not need to specify plsql.connection (this is also safer when ActiveRecord reestablishes connection to database).
118
+
119
+ INSTALLATION
120
+ ------------
121
+
122
+ Install as gem with
123
+
124
+ gem install ruby-plsql
125
+
126
+ or include gem in Gemfile if using bundler.
127
+
128
+ In addition install either ruby-oci8 (for MRI/YARV) or copy Oracle JDBC driver to $JRUBY_HOME/lib (for JRuby).
129
+
130
+ If you are using MRI 1.8 or 1.9 Ruby implementation then you need to install ruby-oci8 gem (version 2.0.x or 2.1.x)
131
+ as well as Oracle client, e.g. [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html).
132
+
133
+ If you are using JRuby then you need to download latest [Oracle JDBC driver](http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html) - either ojdbc6.jar for Java 6 or ojdbc5.jar for Java 5. And copy this file to one of these locations:
134
+
135
+ * in `./lib` directory of Rails application and require it manually
136
+ * in some directory which is in `PATH`
137
+ * in `JRUBY_HOME/lib` directory
138
+ * or include path to JDBC driver jar file in Java `CLASSPATH`
139
+
140
+
141
+ LINKS
142
+ -----
143
+
144
+ * Source code: http://github.com/rsim/ruby-plsql
145
+ * Bug reports / Feature requests: http://github.com/rsim/ruby-plsql/issues
146
+ * Discuss at oracle_enhanced adapter group: http://groups.google.com/group/oracle-enhanced
147
+
148
+ CONTRIBUTORS
149
+ ------------
150
+
151
+ * Raimonds Simanovskis
152
+ * Edgars Beigarts
153
+ * Oleh Mykytyuk
154
+ * Wiehann Matthysen
155
+ * Dayle Larson
156
+ * Yasuo Honda
157
+
158
+ LICENSE
159
+ -------
160
+
161
+ (The MIT License)
162
+
163
+ Copyright (c) 2008-2012 Raimonds Simanovskis
164
+
165
+ Permission is hereby granted, free of charge, to any person obtaining
166
+ a copy of this software and associated documentation files (the
167
+ 'Software'), to deal in the Software without restriction, including
168
+ without limitation the rights to use, copy, modify, merge, publish,
169
+ distribute, sublicense, and/or sell copies of the Software, and to
170
+ permit persons to whom the Software is furnished to do so, subject to
171
+ the following conditions:
172
+
173
+ The above copyright notice and this permission notice shall be
174
+ included in all copies or substantial portions of the Software.
175
+
176
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
177
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
178
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
179
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
180
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
181
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
182
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+
11
+ require 'rake'
12
+
13
+ require 'jeweler'
14
+ Jeweler::Tasks.new do |gem|
15
+ gem.name = "ruby-plsql"
16
+ gem.summary = "Ruby API for calling Oracle PL/SQL procedures."
17
+ gem.description = <<-EOS
18
+ ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures.
19
+ It could be used both for accessing Oracle PL/SQL API procedures in legacy applications
20
+ as well as it could be used to create PL/SQL unit tests using Ruby testing libraries.
21
+ EOS
22
+ gem.email = "raimonds.simanovskis@gmail.com"
23
+ gem.homepage = "http://github.com/rsim/ruby-plsql"
24
+ gem.authors = ["Raimonds Simanovskis"]
25
+ gem.extra_rdoc_files = ['README.md']
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec)
31
+
32
+ RSpec::Core::RakeTask.new(:rcov) do |t|
33
+ t.rcov = true
34
+ t.rcov_opts = ['--exclude', '/Library,spec/']
35
+ end
36
+
37
+ task :default => :spec
38
+
39
+ require 'rdoc/task'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
+
43
+ rdoc.rdoc_dir = 'doc'
44
+ rdoc.title = "ruby-plsql #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end