ruby-plsql 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- .bundle
2
- .rvmrc
3
- .svn
4
- .DS_Store
5
- coverage
6
- doc
7
- pkg
8
- log
9
- tmp
10
- sqlnet.log
11
- Gemfile.lock
data/README.rdoc DELETED
@@ -1,158 +0,0 @@
1
- = ruby-plsql
2
-
3
- Ruby API for calling Oracle PL/SQL procedures.
4
-
5
- == DESCRIPTION
6
-
7
- 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.
8
-
9
- 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.
10
-
11
- ruby-plsql supports both Ruby 1.8 MRI, Ruby 1.9.1 YARV and JRuby 1.3/1.4 runtime environments.
12
-
13
- == USAGE
14
-
15
- === Calling PL/SQL functions and procedures:
16
-
17
- require "rubygems"
18
- require "ruby-plsql"
19
-
20
- plsql.connection = OCI8.new("hr","hr","xe")
21
-
22
- plsql.test_uppercase('xxx') # => "XXX"
23
- plsql.test_uppercase(:p_string => 'xxx') # => "XXX"
24
- plsql.test_copy("abc", nil, nil) # => { :p_to => "abc", :p_to_double => "abcabc" }
25
- plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil)
26
- # => { :p_to => "abc", :p_to_double => "abcabc" }
27
- plsql.hr.test_uppercase('xxx') # => "XXX"
28
- plsql.test_package.test_uppercase('xxx') # => 'XXX'
29
-
30
- # PL/SQL records or object type parameters should be passed as Hash
31
- p_employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31) }
32
- plsql.test_full_name(p_employee)
33
-
34
- # TABLE or VARRAY parameters should be passed as Array
35
- plsql.test_sum([1,2,3,4])
36
-
37
- # Nested objects or arrays are also supported
38
- p_employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31),
39
- :address => {:street => 'Street', :city => 'City', :country => 'Country'},
40
- :phones => [{:type => 'mobile', :phone_number => '123456'}, {:type => 'fixed', :phone_number => '654321'}]}
41
- plsql.test_store_employee(p_employee)
42
-
43
- # Returned cursor can be fetched
44
- plsql.test_cursor do |cursor|
45
- cursor.fetch # => one row from cursor
46
- cursor.fetch_all # => all rows from cursor
47
- end
48
-
49
- plsql.connection.autocommit = false
50
- plsql.commit
51
- plsql.rollback
52
-
53
- plsql.logoff
54
-
55
- Look at RSpec tests under spec directory for more usage examples.
56
-
57
-
58
- === Table operations:
59
-
60
- 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):
61
-
62
- # insert record in table
63
- employee = { :employee_id => 1, :first_name => 'First', :last_name => 'Last', :hire_date => Time.local(2000,01,31) }
64
- plsql.employees.insert employee # INSERT INTO employees VALUES (1, 'First', 'Last', ...)
65
-
66
- # insert many records
67
- employees = [employee1, employee2, ... ] # array of many Hashes
68
- plsql.employees.insert employees
69
-
70
- # insert many records as list of values
71
- plsql.employees.insert_values [:employee_id, :first_name, :last_name],
72
- [1, 'First 1', 'Last 1'],
73
- [2, 'First 2', 'Last 2']
74
-
75
- # select one record
76
- plsql.employees.first # SELECT * FROM employees
77
- # fetch first row => {:employee_id => ..., :first_name => '...', ...}
78
- plsql.employees.first(:employee_id => 1) # SELECT * FROM employees WHERE employee_id = 1
79
- plsql.employees.first("WHERE employee_id = 1")
80
- plsql.employees.first("WHERE employee_id = :employee_id", 1)
81
-
82
- # select many records
83
- plsql.employees.all # => [{...}, {...}, ...]
84
- plsql.employees.all(:order_by => :employee_id)
85
- plsql.employees.all("WHERE employee_id > :employee_id", 5)
86
-
87
- # count records
88
- plsql.employees.count # SELECT COUNT(*) FROM employees
89
- plsql.employees.count("WHERE employee_id > :employee_id", 5)
90
-
91
- # update records
92
- plsql.employees.update(:first_name => 'Second', :where => {:employee_id => 1})
93
- # UPDATE employees SET first_name = 'Second' WHERE employee_id = 1
94
-
95
- # delete records
96
- plsql.employees.delete(:employee_id => 1) # DELETE FROM employees WHERE employee_id = 1
97
-
98
- # select from sequences
99
- plsql.employees_seq.nextval # SELECT employees_seq.NEXTVAL FROM dual
100
- plsql.employees_seq.currval # SELECT employees_seq.CURRVAL FROM dual
101
-
102
-
103
- === Usage with Rails:
104
-
105
- If using with Rails then include in initializer file:
106
-
107
- plsql.activerecord_class = ActiveRecord::Base
108
-
109
- and then you do not need to specify plsql.connection (this is also safer when ActiveRecord reestablishes connection to database).
110
-
111
- == REQUIREMENTS:
112
-
113
- Ruby 1.8.6/1.8.7 MRI / Ruby 1.9.1 YARV
114
- * Requires ruby-oci8 library (please use version 2.0.3 or later)
115
- JRuby 1.3/1.4
116
- * Requires Oracle JDBC driver (ojdbc14.jar should be somewhere in PATH or should be available for Java class loader)
117
-
118
- == INSTALL:
119
-
120
- * [sudo] gem install ruby-plsql
121
-
122
- In addition install either ruby-oci8 (for MRI/YARV) or copy Oracle JDBC driver to $JRUBY_HOME/lib (for JRuby).
123
-
124
- == LINKS
125
-
126
- * Source code: http://github.com/rsim/ruby-plsql
127
- * Bug reports / Feature requests: http://github.com/rsim/ruby-plsql/issues
128
- * Discuss at oracle_enhanced adapter group: http://groups.google.com/group/oracle-enhanced
129
-
130
- == CONTRIBUTORS:
131
-
132
- * Raimonds Simanovskis
133
- * Edgars Beigarts
134
-
135
- == LICENSE:
136
-
137
- (The MIT License)
138
-
139
- Copyright (c) 2008-2010 Raimonds Simanovskis
140
-
141
- Permission is hereby granted, free of charge, to any person obtaining
142
- a copy of this software and associated documentation files (the
143
- 'Software'), to deal in the Software without restriction, including
144
- without limitation the rights to use, copy, modify, merge, publish,
145
- distribute, sublicense, and/or sell copies of the Software, and to
146
- permit persons to whom the Software is furnished to do so, subject to
147
- the following conditions:
148
-
149
- The above copyright notice and this permission notice shall be
150
- included in all copies or substantial portions of the Software.
151
-
152
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
153
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
154
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
155
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
156
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
157
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
158
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.