ruby-oci8 1.0.2-i386-mswin32
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/ChangeLog +569 -0
- data/Makefile +51 -0
- data/NEWS +322 -0
- data/README +415 -0
- data/VERSION +1 -0
- data/dist-files +70 -0
- data/doc/api.en.html +527 -0
- data/doc/api.en.rd +554 -0
- data/doc/api.ja.html +525 -0
- data/doc/api.ja.rd +557 -0
- data/doc/manual.css +35 -0
- data/ext/oci8/oci8lib.so +0 -0
- data/lib/DBD/OCI8/OCI8.rb +549 -0
- data/lib/oci8.rb +1605 -0
- data/lib/oci8.rb.in +1605 -0
- data/metaconfig +142 -0
- data/pre-distclean.rb +7 -0
- data/ruby-oci8.gemspec +54 -0
- data/ruby-oci8.spec +62 -0
- data/setup.rb +1331 -0
- data/support/README +4 -0
- data/support/runit/assert.rb +281 -0
- data/support/runit/cui/testrunner.rb +101 -0
- data/support/runit/error.rb +4 -0
- data/support/runit/method_mappable.rb +20 -0
- data/support/runit/robserver.rb +25 -0
- data/support/runit/setuppable.rb +15 -0
- data/support/runit/teardownable.rb +16 -0
- data/support/runit/testcase.rb +113 -0
- data/support/runit/testfailure.rb +25 -0
- data/support/runit/testresult.rb +121 -0
- data/support/runit/testsuite.rb +43 -0
- data/support/runit/version.rb +3 -0
- data/test/README +4 -0
- data/test/config.rb +129 -0
- data/test/test_all.rb +43 -0
- data/test/test_bind_raw.rb +53 -0
- data/test/test_bind_time.rb +191 -0
- data/test/test_break.rb +81 -0
- data/test/test_clob.rb +101 -0
- data/test/test_connstr.rb +80 -0
- data/test/test_dbi.rb +317 -0
- data/test/test_dbi_clob.rb +56 -0
- data/test/test_describe.rb +137 -0
- data/test/test_metadata.rb +243 -0
- data/test/test_oci8.rb +273 -0
- data/test/test_oradate.rb +263 -0
- data/test/test_oranumber.rb +149 -0
- metadata +97 -0
data/Makefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
VERSION = `cat VERSION`
|
2
|
+
RUBY = ruby
|
3
|
+
GEM = gem
|
4
|
+
CONFIG_OPT =
|
5
|
+
|
6
|
+
all: build
|
7
|
+
|
8
|
+
build: config.save setup
|
9
|
+
|
10
|
+
config.save: lib/oci8.rb.in
|
11
|
+
$(RUBY) setup.rb config $(CONFIG_OPT)
|
12
|
+
|
13
|
+
setup:
|
14
|
+
$(RUBY) setup.rb setup
|
15
|
+
|
16
|
+
check: build
|
17
|
+
$(RUBY) setup.rb test
|
18
|
+
|
19
|
+
clean:
|
20
|
+
$(RUBY) setup.rb clean
|
21
|
+
|
22
|
+
distclean:
|
23
|
+
$(RUBY) setup.rb distclean
|
24
|
+
|
25
|
+
install:
|
26
|
+
$(RUBY) setup.rb install
|
27
|
+
|
28
|
+
site-install:
|
29
|
+
$(RUBY) setup.rb install
|
30
|
+
|
31
|
+
gem:
|
32
|
+
$(GEM) build ruby-oci8.gemspec
|
33
|
+
|
34
|
+
binary_gem: build
|
35
|
+
$(GEM) build ruby-oci8.gemspec -- current
|
36
|
+
|
37
|
+
# internal use only
|
38
|
+
dist: ruby-oci8.spec
|
39
|
+
-rm -rf ruby-oci8-$(VERSION)
|
40
|
+
mkdir ruby-oci8-$(VERSION)
|
41
|
+
tar cf - `cat dist-files` | (cd ruby-oci8-$(VERSION); tar xf - )
|
42
|
+
tar cfz ruby-oci8-$(VERSION).tar.gz ruby-oci8-$(VERSION)
|
43
|
+
|
44
|
+
dist-check: dist
|
45
|
+
cd ruby-oci8-$(VERSION) && $(MAKE) RUBY="$(RUBY)"
|
46
|
+
cd ruby-oci8-$(VERSION) && $(MAKE) RUBY="$(RUBY)" check
|
47
|
+
cd ruby-oci8-$(VERSION)/src && $(MAKE) RUBY="$(RUBY)" sitearchdir=../work sitelibdir=../work site-install
|
48
|
+
cd ruby-oci8-$(VERSION)/test && $(RUBY) -I../work -I../support test_all.rb
|
49
|
+
|
50
|
+
ruby-oci8.spec: ruby-oci8.spec.in
|
51
|
+
$(RUBY) -rerb -e "open('ruby-oci8.spec', 'w').write(ERB.new(open('ruby-oci8.spec.in').read).result)"
|
data/NEWS
ADDED
@@ -0,0 +1,322 @@
|
|
1
|
+
1.0.2:
|
2
|
+
|
3
|
+
1. add a gemspec file.
|
4
|
+
(Thanks to Jesse Hu)
|
5
|
+
|
6
|
+
To make a pure ruby gems package:
|
7
|
+
gem build ruby-oci8.gemspec
|
8
|
+
|
9
|
+
To make a binary gems package:
|
10
|
+
gem build ruby-oci8.gemspec -- current
|
11
|
+
|
12
|
+
|
13
|
+
2. [BUG FIX] fix a segv bug in gc mark.
|
14
|
+
(Thanks to authorNari)
|
15
|
+
|
16
|
+
1.0.1:
|
17
|
+
|
18
|
+
1. [SPEC CHANGE] OCI8#exec and OCI8::Cursor#exec's return value is changed
|
19
|
+
for statement except select, insert, update and delete statement.
|
20
|
+
|
21
|
+
It had been true. But now it is the number of rows processed for all
|
22
|
+
non-select statements.
|
23
|
+
|
24
|
+
For example:
|
25
|
+
|
26
|
+
# 1.0.0 or before
|
27
|
+
conn = OCI8.new('user/pass')
|
28
|
+
conn.exec('rename FOO_TABLE to BAR_TABLE') # => true
|
29
|
+
|
30
|
+
# 1.0.1
|
31
|
+
conn = OCI8.new('user/pass')
|
32
|
+
conn.exec('rename FOO_TABLE to BAR_TABLE') # => 0
|
33
|
+
|
34
|
+
2. fix a bug that OraDate.new made a core dump on x86_64 linux.
|
35
|
+
(reported by Alun Eyre)
|
36
|
+
|
37
|
+
3. fix OCI8#non_blocking = false problem.
|
38
|
+
Once the connection became non-bocking mode, it could
|
39
|
+
not be reset to blocking mode. Now it can be reset.
|
40
|
+
(reported by Cagdas Gerede)
|
41
|
+
|
42
|
+
4. support cursors in a result set.
|
43
|
+
(contributed by Randy Gordon)
|
44
|
+
|
45
|
+
For example:
|
46
|
+
conn = OCI8.new('ruby/oci8')
|
47
|
+
sql = 'SELECT CURSOR(SELECT * FROM foo where foo.c1 = bar.c1 ) FROM bar'
|
48
|
+
conn.exec(sql) do |row|
|
49
|
+
cursor_in_result_set = row[0]
|
50
|
+
cursor_in_result_set.fetch do |row|
|
51
|
+
puts row.join(',')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
5. fix oraconf.rb for official x86_64 linux rpms.
|
56
|
+
(contributed by Pat)
|
57
|
+
|
58
|
+
1.0.0:
|
59
|
+
|
60
|
+
1. fix a BUG when binding a Bignum. This bug was added in
|
61
|
+
ruby-oci8 1.0.0-rc2. (reported by Daniel Berger)
|
62
|
+
|
63
|
+
2. add OCI8#describe_table(table_name), OCI8::Cursor#column_metadata,
|
64
|
+
OCI8::Metadata::Table, OCI8::Metadata::View and OCI8::Metadata::Column.
|
65
|
+
|
66
|
+
table information:
|
67
|
+
con = OCI8.new('username/password')
|
68
|
+
table_info = con.describe_table('table_name') #=> OCI8::Metadata::Table
|
69
|
+
table_info.columns #=> an array of OCI8::Metadata::Column.
|
70
|
+
|
71
|
+
query information:
|
72
|
+
con = OCI8.new('username/password')
|
73
|
+
csr = con.exec('select * from table_name')
|
74
|
+
csr.column_metadata #=> an array of OCI8::Metadata::Column.
|
75
|
+
|
76
|
+
5. add OCI8::BindType::BinaryDouble if oci8lib.so is compiled for
|
77
|
+
Oracle 10g client. You can fetch exactly same values in Oracle.
|
78
|
+
|
79
|
+
You could fetch the values in previous version by adding the
|
80
|
+
following line.
|
81
|
+
|
82
|
+
OCI8::BindType::Mapping[101] = OCI8::BindType::Float
|
83
|
+
(This is default in ruby-oci8 1.0.0-rc2.)
|
84
|
+
|
85
|
+
But a fetched value may not be exactly same with the value in
|
86
|
+
Oracle. That's because OCI8::BindType::Float's network
|
87
|
+
representation is Oracle NUMBER data type. A BINARY_DOUBLE
|
88
|
+
value in Oracle become NUMBER on the network and is converted
|
89
|
+
to Float on the client side. It makes a bit difference by
|
90
|
+
round-off error.
|
91
|
+
|
92
|
+
In addition, Oracle NUMBER doesn't have NaN, +Infinity and -Infinity.
|
93
|
+
You cannot fetch the values by older versions.
|
94
|
+
|
95
|
+
Note: When you bind a Float value, it is bound by
|
96
|
+
OCI8::BindType::Float by default. You have two ways to bind
|
97
|
+
it by OCI8::BindType::BinaryDouble.
|
98
|
+
|
99
|
+
a. bind explicitly.
|
100
|
+
|
101
|
+
con = OCI8.new('ruby/oci8')
|
102
|
+
csr = con.parse('insert into table_name values (:1)')
|
103
|
+
csr.bind_param(1, 10.5, OCI8::SQLT_IBDOUBLE)
|
104
|
+
csr.exec
|
105
|
+
|
106
|
+
b. change the default behaviour if and only if you are sure that
|
107
|
+
the Oracle client version and Oracle server version are both
|
108
|
+
10g or upper.
|
109
|
+
|
110
|
+
# use OCI8::BindType::BinaryDouble for ruby's Float values.
|
111
|
+
OCI8::BindType::Mapping[Float] = OCI8::BindType::BinaryDouble
|
112
|
+
con = OCI8.new('ruby/oci8')
|
113
|
+
csr = con.exec('insert into table_name values (:1)', 10.5)
|
114
|
+
|
115
|
+
4. OCI8::Cursor#fetch_hash accepts a block as a iterator.
|
116
|
+
|
117
|
+
5. [dbi] support external OS authentication.
|
118
|
+
(contributed by Dan Fitch)
|
119
|
+
|
120
|
+
dbh = DBI.connect('dbi:OCI8', nil, nil)
|
121
|
+
|
122
|
+
6. [dbi] add DatabaseHandle#columns and improve StatementHandle#column_info
|
123
|
+
(suggested by Venkat Pa)
|
124
|
+
|
125
|
+
7. [bug] fix a problem when binding ''(empty string) via dbi.
|
126
|
+
|
127
|
+
1.0.0-rc3:
|
128
|
+
|
129
|
+
1. support external OS authentication.
|
130
|
+
(suggested by Dan Fitch)
|
131
|
+
|
132
|
+
conn = OCI8.new('/')
|
133
|
+
or
|
134
|
+
conn = OCI8.new(nil, nil)
|
135
|
+
|
136
|
+
2. incompatible change on connect string.
|
137
|
+
|
138
|
+
You need to pass only one argument to OCI8.new to parse the
|
139
|
+
first argument as a SQL*Plus-like connect string.
|
140
|
+
|
141
|
+
For example, OCI8.new('scott/tiger', nil) was parsed as the
|
142
|
+
username is 'scott' and the password is 'tiger' in 1.0.0-rc2.
|
143
|
+
But from now on, it is treated as the username is 'scott/tiger'
|
144
|
+
and the password is nil because it has two arguments. You need
|
145
|
+
to use OCI8.new('scott/tiger') instead.
|
146
|
+
|
147
|
+
3. fix NCLOB support on Oracle 9i.
|
148
|
+
(reported by Matthew Noble)
|
149
|
+
|
150
|
+
1.0.0-rc2's NCLOB support worked on Oracle 10g only.
|
151
|
+
|
152
|
+
4. fix a problem to compile with a third-party x86_64 rpm package.
|
153
|
+
(contributed by Jeff Abbott)
|
154
|
+
|
155
|
+
The x86_64 source rpm packages are found on the following URLs.
|
156
|
+
http://freshrpms.net/docs/oracle/
|
157
|
+
http://remi.collet.free.fr/index.php?2007/01/22/279-oracle-instant-client-10203-on-x86_64
|
158
|
+
|
159
|
+
5. '--with-instant-client' option become obsolete and is ignored.
|
160
|
+
|
161
|
+
Use LD_LIBRARY_PATH(Linux), PATH(Windows), etc. to indicate
|
162
|
+
the instant client's location.
|
163
|
+
|
164
|
+
6. fix some other minor problems.
|
165
|
+
|
166
|
+
1.0.0-rc2:
|
167
|
+
|
168
|
+
1. support SQL*Plus-like connect strings.
|
169
|
+
(contributed by Oracle Corporation)
|
170
|
+
|
171
|
+
require 'oci8'
|
172
|
+
conn = OCI8.new('username/password@tns_name')
|
173
|
+
# instead of OCI8.new('username', 'password', 'tns_name')
|
174
|
+
|
175
|
+
2. Add a rpm spec file.
|
176
|
+
(contributed by Brian Candler)
|
177
|
+
|
178
|
+
rpmbuild -tb ruby-oci8-x.y.z.tar.gz
|
179
|
+
|
180
|
+
/usr/src/redhat/RPMS/i386/ruby-oci8-x.y.z-1.i386.rpm
|
181
|
+
|
182
|
+
3. support BINARY_FLOAT and BINADY_DOUBLE columns.
|
183
|
+
(This problem is reported by Duncan McCaffery.)
|
184
|
+
|
185
|
+
4. support NCLOB columns.
|
186
|
+
(This problem is reported by Dmitry Zadvornykh.)
|
187
|
+
|
188
|
+
cursor = conn.exec('select nclob_column from nclob_table')
|
189
|
+
cursor.fetch # => [ instance of OCI8::NCLOB ]
|
190
|
+
|
191
|
+
5. add new CLOB/NCLOB/BLOB insert method.
|
192
|
+
(This is available on Oracle 8.1.5 or later.)
|
193
|
+
|
194
|
+
cursor = conn.parse("INSERT INTO clob_table VALUES (:1)")
|
195
|
+
cursor.bind_param(1, OCI8::CLOB.new(conn, lob_data))
|
196
|
+
cursor.exec
|
197
|
+
|
198
|
+
cursor = conn.parse("INSERT INTO nclob_table VALUES (:1)")
|
199
|
+
cursor.exec(OCI8::NCLOB.new(conn, lob_data))
|
200
|
+
|
201
|
+
conn.exec("INSERT INTO blob_table VALUES (:1)",
|
202
|
+
OCI8::BLOB.new(conn, lob_data))
|
203
|
+
|
204
|
+
This is added to insert CLOB as a SDO_GEOMETRY's parameter
|
205
|
+
to solve a problem reported by Pete Schwamb.
|
206
|
+
|
207
|
+
6. add an error location in C code to OCIException's backtrace.
|
208
|
+
This is for debug information.
|
209
|
+
|
210
|
+
1.0.0-rc1:
|
211
|
+
|
212
|
+
1. support BFILE columns.
|
213
|
+
|
214
|
+
2. check whether Full Client or Instant Client by checking load library
|
215
|
+
path on configuration to compile.
|
216
|
+
|
217
|
+
3. raise an OCIError with "OCI Library Initialization Error" message if
|
218
|
+
no message can not be retrieved when requiring oci8lib.so.
|
219
|
+
|
220
|
+
4. raise "OCI Library Initialization Error" when first connect instead
|
221
|
+
of requiring oci8lib.so. This is a workaround to prevent Rails from
|
222
|
+
being stopped on invalid Oracle environment.
|
223
|
+
|
224
|
+
0.1.16:
|
225
|
+
|
226
|
+
1. Add LONG and LONG RAW support longer than 65535 bytes.
|
227
|
+
|
228
|
+
Use OCI8#long_read_len and OCI8#long_read_len= to set max long length.
|
229
|
+
The default value is 65535.
|
230
|
+
|
231
|
+
2. OraDate and OraNumber can be serialized by Marshal now.
|
232
|
+
|
233
|
+
3. OraDate and OraNumber can be serialized by YAML now.
|
234
|
+
|
235
|
+
4. Fix bug on OraDate#dup, OraDate#clone, OraNumber#dup and OraNumber#clone.
|
236
|
+
(reported by Daniel Berger.)
|
237
|
+
|
238
|
+
These methods had not duplicated their contents, which caused segmentation
|
239
|
+
fault. Now they duplicate their contents also by adding initialize_copy
|
240
|
+
method.
|
241
|
+
|
242
|
+
5. Add a workaround code on cygwin environment variables problem.
|
243
|
+
|
244
|
+
Cygwin manages environment variables by itself. They don't synchroize
|
245
|
+
with Win32's ones. When setting Oracle's environment variables, they
|
246
|
+
are set to cygwin's environment. But Oracle client library read
|
247
|
+
Win32's. Now Oracle-related variables are forcedly set to Win32.
|
248
|
+
|
249
|
+
6. Accept all Fixnum values when binding as a Fixnum on 64-bit ruby.
|
250
|
+
|
251
|
+
A Fixnum is a 31-bit integer on 32-bit ruby, 63-bit integer on 64-bit
|
252
|
+
ruby. But it had been bound to 32-bit integer on ruby-oci8. Now it is
|
253
|
+
bound to integer whose bit width is same with ruby.
|
254
|
+
|
255
|
+
0.1.15:
|
256
|
+
|
257
|
+
1. no new features. :-<
|
258
|
+
|
259
|
+
2. suppress memory usage when binding a placeholder which is already bound.
|
260
|
+
|
261
|
+
require 'oci8'
|
262
|
+
conn = OCI8.new('ruby', 'oci8')
|
263
|
+
cursor = conn.parse('select * from foo where key = :key')
|
264
|
+
0.upto(10000) do |key|
|
265
|
+
# bind values had not freed until cursor.close.
|
266
|
+
# Now they are freed when GC is run.
|
267
|
+
cursor.bind_param('key', key)
|
268
|
+
cursor.exec
|
269
|
+
.... fetch ....
|
270
|
+
end
|
271
|
+
|
272
|
+
3. fix potentially segmentation fault while exiting process.
|
273
|
+
When exiting process, ruby's objects are GCed with unexpectable
|
274
|
+
order. If an OCIEnv instance was GCed in prior to OCIRowid objects,
|
275
|
+
it caused segmentation fault.
|
276
|
+
|
277
|
+
4. add a workaround code when setting $0.
|
278
|
+
The following code made enviroment variables empty strings on
|
279
|
+
Unix when using ruby 1.8.4, ruby-oci8 0.1.14 and Oracle 10.1.0.
|
280
|
+
(Oracle 10.2.0 and ruby 1.8.2 doesn't have this problem.)
|
281
|
+
|
282
|
+
require 'oci8'
|
283
|
+
ENV['HOME'] # --> valid value
|
284
|
+
$0 = 'foo'
|
285
|
+
ENV['HOME'] # --> ''
|
286
|
+
|
287
|
+
5. fix registry search path on compilation.
|
288
|
+
(OracleXE Windows version)
|
289
|
+
|
290
|
+
0.1.14:
|
291
|
+
|
292
|
+
1. add OCI8#prefetch_rows=.
|
293
|
+
|
294
|
+
This specifies the number of rows in a single round trip.
|
295
|
+
See: http://www.easysoft.com/products/data_access/odbc_oracle_driver/performance_tuning_guide.html#multiple_rows
|
296
|
+
In addition, setting zero may become a workaround
|
297
|
+
of some Oracle internal problems.
|
298
|
+
The default value is one.
|
299
|
+
|
300
|
+
2. fix bug when binding a Bignum.
|
301
|
+
3. (low-level API) add attrSet(OCI_ATTR_DESC_PUBLIC, -1).
|
302
|
+
4. (low-level API) add a constant OCI_PTYPE_UNK.
|
303
|
+
5. (internal) use OCIEnv.logon when no priviledge login.
|
304
|
+
6. (internal) delete code to register malloc/realloc/free callbacks to OCI.
|
305
|
+
|
306
|
+
0.1.13:
|
307
|
+
|
308
|
+
1. fix a memory leak.
|
309
|
+
(fixed by Nathaniel Talbott.)
|
310
|
+
|
311
|
+
It is recommended to update to 0.1.13 if a program executes many
|
312
|
+
queries. That's bacause 0.1.12 cause 70-byte memory leak per a
|
313
|
+
query.
|
314
|
+
|
315
|
+
2. ruby's DateTime support is added.
|
316
|
+
(suggested by Daniel Berger.)
|
317
|
+
|
318
|
+
To fetch Oracle's DATE datatype as ruby's DateTime by default, add
|
319
|
+
the following code to your program.
|
320
|
+
|
321
|
+
OCI8::BindType::Mapping[OCI8::SQLT_DAT] = OCI8::BindType::DateTime
|
322
|
+
OCI8::BindType::Mapping[OCI8::SQLT_TIMESTAMP] = OCI8::BindType::DateTime
|
data/README
ADDED
@@ -0,0 +1,415 @@
|
|
1
|
+
= How to make
|
2
|
+
|
3
|
+
== Oracle Full Client (not Oracle Instant Client)
|
4
|
+
|
5
|
+
1. check the followings:
|
6
|
+
- ruby and make (or nmake on MSVC) are in the environment variable PATH.
|
7
|
+
- sqlplus runs correctly.
|
8
|
+
|
9
|
+
2. check library search path.
|
10
|
+
|
11
|
+
If sqlplus runs correctly, the environments variables are okay in general.
|
12
|
+
But if Oracle is 64-bit and ruby is 32-bit, make sure $ORACLE_HOME/lib32
|
13
|
+
in 32-bit library search path. (LD_LIBRARY_PATH_32 on Solaris, SHLIB_PATH
|
14
|
+
on HP-UX PA-RISC.)
|
15
|
+
|
16
|
+
3. make and install
|
17
|
+
gzip -dc ruby-oci8-0.1.xx.tar.gz | tar xvf -
|
18
|
+
cd ruby-oci8-0.1.xx
|
19
|
+
make # or nmake on MSVC.
|
20
|
+
make install
|
21
|
+
|
22
|
+
== Oracle Instant Client
|
23
|
+
|
24
|
+
1. donwload "Instant Client Package - Basic" and "Instant Client Package - SDK".
|
25
|
+
|
26
|
+
OTN (Oracle Technology Network):
|
27
|
+
URL:http://otn.oracle.com/
|
28
|
+
Instant Client Donload Page:
|
29
|
+
http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
|
30
|
+
|
31
|
+
note:
|
32
|
+
download 32-bit packages for 32-bit ruby even though your OS is 64-bit.
|
33
|
+
|
34
|
+
2. install Oracle Instant Client Packages.
|
35
|
+
|
36
|
+
zip packages:
|
37
|
+
|
38
|
+
mkdir /opt
|
39
|
+
mkdir /opt/oracle
|
40
|
+
cd /opt/oracle
|
41
|
+
unzip path/to/instantclient-basic-XXXX-10.1.0.X.zip
|
42
|
+
unzip path/to/instantclient-sdk-XXXX-10.1.0.X.zip
|
43
|
+
|
44
|
+
rpm packages:
|
45
|
+
|
46
|
+
rpm -i path/to/oracle-instantclient-basic-10.1.0.X-X.XXX.rpm
|
47
|
+
rpm -i path/to/oracle-instantclient-devel-10.1.0.X-X.XXX.rpm
|
48
|
+
|
49
|
+
note for Debian user:
|
50
|
+
convert rpm packages to deb packages by alien.
|
51
|
+
alien path/to/oracle-instantclient-basic-10.1.0.X-X.XXX.rpm
|
52
|
+
alien path/to/oracle-instantclient-devel-10.1.0.X-X.XXX.rpm
|
53
|
+
dpkg -i oracle-instantclient-basic_10.1.0.X-X_XXX.deb
|
54
|
+
dpkg -i oracle-instantclient-devel_10.1.0.X-X_XXX.deb
|
55
|
+
|
56
|
+
3. check installed libraries. (UNIX zip packages only)
|
57
|
+
|
58
|
+
If /opt/oracle/instantclient10_1/libclntsh.so not found,
|
59
|
+
make a symbolic link.
|
60
|
+
|
61
|
+
cd /opt/oracle/instantclient10_1
|
62
|
+
ln -s libclntsh.so.10.1 libclntsh.so
|
63
|
+
|
64
|
+
note:
|
65
|
+
libclntsh.sl for HP-UX PA-RISC
|
66
|
+
libclntsh.dylib for Mac OS X
|
67
|
+
|
68
|
+
4. set library search path.
|
69
|
+
|
70
|
+
Windows:
|
71
|
+
add c:\oracle\instantclient10_1 to PATH.
|
72
|
+
|
73
|
+
AIX:
|
74
|
+
add /opt/oracle/instantclient10_1 to LIBPATH.
|
75
|
+
|
76
|
+
HP-UX PA-RISC 32-bit ruby:
|
77
|
+
add /opt/oracle/instantclient10_1 to SHLIB_PATH.
|
78
|
+
|
79
|
+
SPARC/Solaris 32-bit ruby:
|
80
|
+
add /opt/oracle/instantclient10_1 to LD_LIBRARY_PATH_32.
|
81
|
+
|
82
|
+
SPARC/Solaris 64-bit ruby:
|
83
|
+
add /opt/oracle/instantclient10_1 to LD_LIBRARY_PATH_64.
|
84
|
+
|
85
|
+
Mac OS X:
|
86
|
+
add /opt/oracle/instantclient10_1 to DYLD_LIBRARY_PATH.
|
87
|
+
|
88
|
+
Others:
|
89
|
+
add /opt/oracle/instantclient10_1 to LD_LIBRARY_PATH.
|
90
|
+
|
91
|
+
5. make and install.
|
92
|
+
|
93
|
+
zip packages:
|
94
|
+
gzip -dc ruby-oci8-0.1.xx.tar.gz | tar xvf -
|
95
|
+
cd ruby-oci8-0.1.xx
|
96
|
+
ruby setup.rb config -- --with-instant-client=/opt/oracle/instantclient10_1
|
97
|
+
make
|
98
|
+
make install
|
99
|
+
|
100
|
+
rpm packages:
|
101
|
+
gzip -dc ruby-oci8-0.1.xx.tar.gz | tar xvf -
|
102
|
+
cd ruby-oci8-0.1.xx
|
103
|
+
ruby setup.rb config -- --with-instant-client
|
104
|
+
make
|
105
|
+
make install
|
106
|
+
|
107
|
+
== On compilation failure
|
108
|
+
|
109
|
+
Please report the following information to kubo@jiubao.org.
|
110
|
+
|
111
|
+
* last 100 lines of 'ext/oci8/mkmf.log'.
|
112
|
+
* the results of the following commands:
|
113
|
+
ruby --version
|
114
|
+
ruby -r rbconfig -e "p Config::CONFIG['host']"
|
115
|
+
ruby -r rbconfig -e "p Config::CONFIG['CC']"
|
116
|
+
ruby -r rbconfig -e "p Config::CONFIG['CFLAGS']"
|
117
|
+
ruby -r rbconfig -e "p Config::CONFIG['LDSHARED']"
|
118
|
+
ruby -r rbconfig -e "p Config::CONFIG['LDFLAGS']"
|
119
|
+
ruby -r rbconfig -e "p Config::CONFIG['DLDLAGS']"
|
120
|
+
ruby -r rbconfig -e "p Config::CONFIG['LIBS']"
|
121
|
+
ruby -r rbconfig -e "p Config::CONFIG['GNU_LD']"
|
122
|
+
* if you use gcc:
|
123
|
+
gcc --print-prog-name=ld
|
124
|
+
gcc --print-prog-name=as
|
125
|
+
* on platforms which can use both 32bit/64bit binaries:
|
126
|
+
file $ORACLE_HOME/bin/oracle # Full Client only
|
127
|
+
file `which ruby`
|
128
|
+
echo $LD_LIBRARY_PATH
|
129
|
+
echo $LIBPATH # AIX
|
130
|
+
echo $SHLIB_PATH # HP-UX PA-RISC
|
131
|
+
echo $DYLD_LIBRARY_PATH # Mac OS X
|
132
|
+
echo $LD_LIBRARY_PATH_32 # Solaris
|
133
|
+
|
134
|
+
= How to run
|
135
|
+
|
136
|
+
== Oracle Full Client (not Oracle Instant Client)
|
137
|
+
|
138
|
+
1. set environmet variables.
|
139
|
+
|
140
|
+
The follwing environmet variables are required:
|
141
|
+
|
142
|
+
* ORACLE_HOME
|
143
|
+
UNIX only. This variable is set on registry on Windows.
|
144
|
+
|
145
|
+
* NLS_LANG
|
146
|
+
UNIX only. This variable is set on registry on Windows.
|
147
|
+
|
148
|
+
* library serach path
|
149
|
+
|
150
|
+
Windows:
|
151
|
+
add %ORACLE_HOME%\bin to PATH.
|
152
|
+
|
153
|
+
AIX:
|
154
|
+
add $ORACLE_HOME/lib to LIBPATH.
|
155
|
+
|
156
|
+
HP-UX PA-RISC 32-bit ruby:
|
157
|
+
add $ORACLE_HOME/lib32 to SHLIB_PATH.
|
158
|
+
If $ORACLE_HOME/lib32 doesn't exist, add $ORACLE_HOME/lib instead.
|
159
|
+
|
160
|
+
SPARC/Solaris 32-bit ruby:
|
161
|
+
add $ORACLE_HOME/lib32 to LD_LIBRARY_PATH_32.
|
162
|
+
If $ORACLE_HOME/lib32 doesn't exist, add $ORACLE_HOME/lib instead.
|
163
|
+
|
164
|
+
SPARC/Solaris 64-bit ruby:
|
165
|
+
add $ORACLE_HOME/lib to LD_LIBRARY_PATH_64.
|
166
|
+
|
167
|
+
Mac OS X:
|
168
|
+
add $ORACLE_HOME/lib to DYLD_LIBRARY_PATH.
|
169
|
+
|
170
|
+
Other 32-bit ruby:
|
171
|
+
add $ORACLE_HOME/lib32 to LD_LIBRARY_PATH.
|
172
|
+
If $ORACLE_HOME/lib32 doesn't exist, add $ORACLE_HOME/lib instead.
|
173
|
+
|
174
|
+
Other 64-bit ruby:
|
175
|
+
add $ORACLE_HOME/lib to LD_LIBRARY_PATH.
|
176
|
+
|
177
|
+
To connect the local database:
|
178
|
+
|
179
|
+
* ORACLE_SID
|
180
|
+
|
181
|
+
2. enjoy.
|
182
|
+
|
183
|
+
sample one-liner:
|
184
|
+
ruby -r oci8 -e 'OCI8.new("scott", "tiger", nil).exec("select * from emp") do |r| puts r.join(","); end'
|
185
|
+
|
186
|
+
== Oracle Instant Client
|
187
|
+
|
188
|
+
1. set environmet variables.
|
189
|
+
|
190
|
+
The follwing environmet variables are required:
|
191
|
+
|
192
|
+
* NLS_LANG
|
193
|
+
|
194
|
+
* library serach path
|
195
|
+
|
196
|
+
Windows:
|
197
|
+
add %ORACLE_HOME%\bin to PATH.
|
198
|
+
|
199
|
+
AIX:
|
200
|
+
add $ORACLE_HOME/lib to LIBPATH.
|
201
|
+
|
202
|
+
HP-UX PA-RISC 32-bit ruby:
|
203
|
+
add $ORACLE_HOME/lib32 to SHLIB_PATH.
|
204
|
+
If $ORACLE_HOME/lib32 doesn't exist, add $ORACLE_HOME/lib instead.
|
205
|
+
|
206
|
+
SPARC/Solaris 32-bit ruby:
|
207
|
+
add $ORACLE_HOME/lib32 to LD_LIBRARY_PATH_32.
|
208
|
+
If $ORACLE_HOME/lib32 doesn't exist, add $ORACLE_HOME/lib instead.
|
209
|
+
|
210
|
+
SPARC/Solaris 64-bit ruby:
|
211
|
+
add $ORACLE_HOME/lib to LD_LIBRARY_PATH_64.
|
212
|
+
|
213
|
+
Mac OS X:
|
214
|
+
add $ORACLE_HOME/lib to DYLD_LIBRARY_PATH.
|
215
|
+
|
216
|
+
Other 32-bit ruby:
|
217
|
+
add $ORACLE_HOME/lib32 to LD_LIBRARY_PATH.
|
218
|
+
If $ORACLE_HOME/lib32 doesn't exist, add $ORACLE_HOME/lib instead.
|
219
|
+
|
220
|
+
Other 64-bit ruby:
|
221
|
+
add $ORACLE_HOME/lib to LD_LIBRARY_PATH.
|
222
|
+
|
223
|
+
ORACLE_HOME and TNS_ADMIN are optional:
|
224
|
+
see: http://www.oracle.com/technology/tech/oci/instantclient/ic-faq.html#A4428
|
225
|
+
|
226
|
+
2. enjoy.
|
227
|
+
|
228
|
+
sample one-liner:
|
229
|
+
ruby -r oci8 -e 'OCI8.new("scott", "tiger", "//HOSTNAME_OR_IP/SID").exec("select * from emp") do |r| puts r.join(","); end'
|
230
|
+
|
231
|
+
== Platform specific topics
|
232
|
+
|
233
|
+
=== HP-UX
|
234
|
+
|
235
|
+
1. I was reported that it doesn't work with 64-bit ruby. :-<
|
236
|
+
|
237
|
+
2. link the libraries which contain thread local storages to ruby itself.
|
238
|
+
|
239
|
+
ruby 1.8.1 or later:
|
240
|
+
gzip -dc ruby-1.8.2.tar.gz | tar xvf -
|
241
|
+
cd ruby-1.8.2
|
242
|
+
./configure --enable-pthread
|
243
|
+
vi Makefile # add "-lcl" to LIBS manually.
|
244
|
+
make
|
245
|
+
make install
|
246
|
+
|
247
|
+
ruby 1.8.0 or 1.6.x:
|
248
|
+
gzip -dc ruby-1.x.x.tar.gz | tar xvf -
|
249
|
+
cd ruby-1.x.x
|
250
|
+
./configure
|
251
|
+
vi Makefile # add "-lpthread -lcl" to LIBS manually.
|
252
|
+
make
|
253
|
+
make install
|
254
|
+
|
255
|
+
If you can't recompile ruby, LD_PRELOAD may solve the problem.
|
256
|
+
|
257
|
+
LD_PRELOAD=/usr/lib/libpthread.1:/usr/lib/libcl.2
|
258
|
+
export LD_PRELOAD
|
259
|
+
|
260
|
+
=== Intel Mac
|
261
|
+
|
262
|
+
Oracle intant client is still, when I write this, pcc.
|
263
|
+
|
264
|
+
1. check whether the ruby is ppc bianry.
|
265
|
+
|
266
|
+
file `which ruby`
|
267
|
+
|
268
|
+
If it is universal bianry, use ditto to extract ppc binary.
|
269
|
+
|
270
|
+
http://blog.sven-tissot.de/daylist_html?year=2006&month=4&day=12
|
271
|
+
|
272
|
+
If it is i386 binary, compie it as ppc.
|
273
|
+
|
274
|
+
2. fix compilation flags.
|
275
|
+
|
276
|
+
ruby -r rbconfig -e "p Config::CONFIG['CFLAGS']"
|
277
|
+
ruby -r rbconfig -e "p Config::CONFIG['DLDLAGS']"
|
278
|
+
|
279
|
+
If they have '-arch i386', delete it from:
|
280
|
+
/usr/lib/ruby/1.8/powerpc-darwin8.0/rbconfig.rb
|
281
|
+
or
|
282
|
+
/usr/lib/ruby/1.8/universal-darwin8.0/rbconfig.rb
|
283
|
+
|
284
|
+
If haven't '-arch ppc', add it.
|
285
|
+
|
286
|
+
3. config, make and install
|
287
|
+
|
288
|
+
ruby setup.rb config -- --with-instant-client=/opt/oracle/instantclient10_1
|
289
|
+
make
|
290
|
+
make install
|
291
|
+
|
292
|
+
4. rollback the changes in 2.
|
293
|
+
|
294
|
+
***************************
|
295
|
+
in progress.
|
296
|
+
|
297
|
+
|
298
|
+
= How to run unit tests
|
299
|
+
|
300
|
+
1. see "How to run"
|
301
|
+
|
302
|
+
2. create user and tables on Oracle.
|
303
|
+
|
304
|
+
- connect to Oracle as system:
|
305
|
+
|
306
|
+
$ sqlplus system/<password_of_system>
|
307
|
+
|
308
|
+
- create user ruby:
|
309
|
+
|
310
|
+
SQL> CREATE USER ruby IDENTIFIED BY oci8;
|
311
|
+
or
|
312
|
+
SQL> CREATE USER ruby IDENTIFIED BY oci8
|
313
|
+
2 DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
|
314
|
+
|
315
|
+
- grant the privilege to connect and execute.
|
316
|
+
|
317
|
+
SQL> GRANT connect, resource, create synonym TO ruby;
|
318
|
+
|
319
|
+
- If the Oracle version is 8i or later:
|
320
|
+
|
321
|
+
SQL> CREATE TABLE ruby.test_clob (filename VARCHAR2(40), content CLOB);
|
322
|
+
|
323
|
+
- connect to Oracle as sys
|
324
|
+
|
325
|
+
$ sqlplus 'sys/<password_of_sys> as sysdba'
|
326
|
+
|
327
|
+
- grant the privilege for the unittest of blocking-mode.
|
328
|
+
|
329
|
+
SQL> GRANT EXECUTE ON dbms_lock TO ruby;
|
330
|
+
|
331
|
+
3. set $dbname in test/config.rb.
|
332
|
+
|
333
|
+
for instant client, or full client which connect the remote server.
|
334
|
+
|
335
|
+
4. run.
|
336
|
+
|
337
|
+
$ make check
|
338
|
+
or
|
339
|
+
$ nmake check (If your compiler is MS Visual C++.)
|
340
|
+
|
341
|
+
|
342
|
+
= How to customize fetched datatypes.
|
343
|
+
|
344
|
+
== OCI8::BindType::Mapping
|
345
|
+
|
346
|
+
OCI8::BindType::Mapping is available to change the mapping of Oracle
|
347
|
+
datatypes and ruby datatypes.
|
348
|
+
|
349
|
+
Examples:
|
350
|
+
fetch a Timestamp value as a OraDate:
|
351
|
+
OCI8::BindType::Mapping[OCI8::SQLT_TIMESTAMP] = OCI8::BindType::OraDate
|
352
|
+
fetch a Timestamp value as a String:
|
353
|
+
OCI8::BindType::Mapping[OCI8::SQLT_TIMESTAMP] = OCI8::BindType::String
|
354
|
+
|
355
|
+
Bind-types are:
|
356
|
+
OCI8::BindType::String
|
357
|
+
OCI8::BindType::RAW
|
358
|
+
OCI8::BindType::OraDate
|
359
|
+
OCI8::BindType::Time
|
360
|
+
OCI8::BindType::Date
|
361
|
+
OCI8::BindType::DateTime (ruby 1.8.0 or upper)
|
362
|
+
OCI8::BindType::Float
|
363
|
+
OCI8::BindType::Fixnum
|
364
|
+
OCI8::BindType::Integer
|
365
|
+
OCI8::BindType::OraNumber
|
366
|
+
OCI8::BindType::Number
|
367
|
+
OCI8::BindType::OCIRowid
|
368
|
+
OCI8::BindType::BLOB
|
369
|
+
OCI8::BindType::CLOB
|
370
|
+
OCI8::BindType::Cursor
|
371
|
+
|
372
|
+
== Number datatype.
|
373
|
+
|
374
|
+
OCI8::BindType::Number is a special bindtype. The actual bindtype
|
375
|
+
depends on the precision and scale.
|
376
|
+
Fixnum or Integer for NUMBER(p, 0). (prec is positive).
|
377
|
+
Float for NUMBER(prec, scale). (prec is less then 15).
|
378
|
+
OraNumber for NUMBER(prec, scale). (prec equals or is greater then 15).
|
379
|
+
|
380
|
+
If fetched value is defiend as NUMBER or calculated value, it is
|
381
|
+
fetched as a Float by default. To customize this behavior, you can
|
382
|
+
use OCI8::BindType::Mapping[:number_unknown_prec] and
|
383
|
+
OCI8::BindType::Mapping[:number_no_prec_setting].
|
384
|
+
|
385
|
+
Oracle 9.2.0.2 or earlier:
|
386
|
+
OCI8::BindType::Mapping[:number_unknown_prec] changes both behaviors.
|
387
|
+
|
388
|
+
Oracle 9.2.0.3 or later:
|
389
|
+
OCI8::BindType::Mapping[:number_no_prec_setting] changes the former.
|
390
|
+
OCI8::BindType::Mapping[:number_unknown_prec] changes the latter.
|
391
|
+
|
392
|
+
Examples:
|
393
|
+
|
394
|
+
CREATE TABLE tab1 (col1 NUMBER, col2 NUMBER(10));
|
395
|
+
SELECT col1 AS col FROM tab1:
|
396
|
+
SELECT col2 * 1.0 AS cal2 FROM tab1;
|
397
|
+
# col : NUMBER whose precision and scale are not defined explicitly.
|
398
|
+
# cal : calculated NUMBER value.
|
399
|
+
|
400
|
+
Oracle 9.2.0.2 or earlier:
|
401
|
+
OCI8::BindType::Mapping[:number_unknown_prec] = OCI8::BindType::Integer
|
402
|
+
==> col is fetched as an Integer.
|
403
|
+
cal is fetched as an Integer.
|
404
|
+
:number_unknown_prec changes the both behaviors.
|
405
|
+
|
406
|
+
Oracle 9.2.0.3 or later:
|
407
|
+
OCI8::BindType::Mapping[:number_unknown_prec] = OCI8::BindType::Integer
|
408
|
+
==> col is fetched as a Float.
|
409
|
+
cal is fetched as an Integer.
|
410
|
+
:number_unknown_prec changes the latter only.
|
411
|
+
|
412
|
+
OCI8::BindType::Mapping[:number_no_prec_setting] = OCI8::BindType::Integer
|
413
|
+
==> col is fetched as an Integer.
|
414
|
+
cal is fetched as a Float.
|
415
|
+
:number_no_prec_setting changes the former only.
|