ruby-oci8 2.0.6-x86-mingw32 → 2.1.0-x86-mingw32
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 +366 -19
- data/Makefile +2 -8
- data/NEWS +111 -0
- data/README +4 -85
- data/VERSION +1 -1
- data/dist-files +9 -2
- data/lib/oci8.rb +19 -13
- data/lib/oci8.rb.in +19 -13
- data/lib/oci8/.document +2 -0
- data/lib/oci8/bindtype.rb +62 -45
- data/lib/oci8/connection_pool.rb +118 -0
- data/lib/oci8/datetime.rb +304 -320
- data/lib/oci8/encoding-init.rb +62 -30
- data/lib/oci8/encoding.yml +3 -3
- data/lib/oci8/metadata.rb +552 -497
- data/lib/oci8/object.rb +9 -9
- data/lib/oci8/oci8.rb +161 -2
- data/lib/oci8/ocihandle.rb +427 -0
- data/lib/oci8/properties.rb +31 -1
- data/lib/oci8lib_18.so +0 -0
- data/lib/oci8lib_191.so +0 -0
- data/ruby-oci8.gemspec +10 -3
- data/test/README +41 -3
- data/test/config.rb +16 -0
- data/test/test_all.rb +3 -0
- data/test/test_bind_string.rb +106 -0
- data/test/test_break.rb +33 -7
- data/test/test_clob.rb +13 -10
- data/test/test_connection_pool.rb +125 -0
- data/test/test_connstr.rb +2 -2
- data/test/test_datetime.rb +26 -66
- data/test/test_encoding.rb +7 -3
- data/test/test_error.rb +88 -0
- data/test/test_metadata.rb +1356 -204
- data/test/test_oci8.rb +27 -8
- data/test/test_oranumber.rb +41 -0
- metadata +10 -5
data/NEWS
CHANGED
@@ -1,3 +1,114 @@
|
|
1
|
+
2.1.0:
|
2
|
+
|
3
|
+
*** Ruby-oci8 2.1.0 doesn't support Oracle 8 (8.0) and Oracle 8i (8.1) anymore. ***
|
4
|
+
|
5
|
+
* New Features
|
6
|
+
|
7
|
+
- OCI connection pooling
|
8
|
+
|
9
|
+
See: http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci09adv.htm#sthref1479
|
10
|
+
and http://docs.oracle.com/cd/E11882_01/java.112/e16548/ociconpl.htm#JJDBC28789
|
11
|
+
|
12
|
+
Example:
|
13
|
+
|
14
|
+
# Create a connection pool.
|
15
|
+
# username and password are required to establish an implicit primary session.
|
16
|
+
cpool = OCI8::ConnectionPool.new(1, 5, 2, username, password, database)
|
17
|
+
|
18
|
+
# Get a session from the pool.
|
19
|
+
# Pass the connection pool to the third argument.
|
20
|
+
conn1 = OCI8.new(username, password, cpool)
|
21
|
+
|
22
|
+
# Get another session.
|
23
|
+
conn2 = OCI8.new(username, password, cpool)
|
24
|
+
|
25
|
+
- Daylight saving time aware if TZ is set.
|
26
|
+
|
27
|
+
You should set the environment variable TZ if your applications run
|
28
|
+
in a time zone with daylight saving time transitions.
|
29
|
+
Otherwise, Oracle session time zone is set with current constant
|
30
|
+
offset from GMT.
|
31
|
+
(reported by Yasuo Honda)
|
32
|
+
|
33
|
+
- connect as sysasm (Oracle 11g only)
|
34
|
+
|
35
|
+
OCI8.new('username/password as sysasm')
|
36
|
+
or
|
37
|
+
OCI8.new('username', 'password', nil, :SYSASM)
|
38
|
+
|
39
|
+
- Oracle number is converted to ruby float exactly same as ruby does.
|
40
|
+
|
41
|
+
From ruby 1.9.2, a float value converted from Oracle number 15.7 by
|
42
|
+
the Oracle function OCINumberToReal() makes a string representation
|
43
|
+
15.700000000000001 by Float#to_s. (See: http://redmine.ruby-lang.org/issues/4656)
|
44
|
+
To avoid this issue, any Oracle number is converted to a float as
|
45
|
+
ruby's String#to_f does.
|
46
|
+
|
47
|
+
The behavior is customizable by OCI8.properties[:float_conversion_type].
|
48
|
+
|
49
|
+
OCI8.properties[:float_conversion_type] = :oracle # => Use OCINumberToReal()
|
50
|
+
OCI8.properties[:float_conversion_type] = :ruby # => Use String#to_f
|
51
|
+
|
52
|
+
The default value is :ruby.
|
53
|
+
|
54
|
+
- OCI_SUCCESS_WITH_INFO handling is changed.
|
55
|
+
|
56
|
+
Ruby-oci8 2.0 treats OCI_SUCCESS_WITH_INFO in OCI layer as an error
|
57
|
+
and raise an exception OCISuccessWithInfo such as "ORA-24347: Warning of
|
58
|
+
a NULL column in an aggregate function" and "ORA-28002: the password will
|
59
|
+
expire within xx days."
|
60
|
+
|
61
|
+
From 2.1.0, it is treated as a warning and the exception is set
|
62
|
+
to OCI8#last_error.
|
63
|
+
|
64
|
+
- OCI8#last_error
|
65
|
+
|
66
|
+
The last error or warning associated with the session is set to
|
67
|
+
OCI8#last_error. The usecase is to detect OCI_SUCCESS_WITH_INFO.
|
68
|
+
It is reset by OCI8#exec and OCI8#parse.
|
69
|
+
|
70
|
+
- Experimental support of character length semantics
|
71
|
+
|
72
|
+
This is enabled when :char is set to OCI8.properties[:length_semantics].
|
73
|
+
|
74
|
+
- OCI8.client_charset_name and OCI8#database_charset_name is added.
|
75
|
+
|
76
|
+
They return Oracle charset name such as WE8ISO8859P15.
|
77
|
+
|
78
|
+
* Specification changes
|
79
|
+
|
80
|
+
- The parent class OCINoData was changed from OCIException to OCIError.
|
81
|
+
|
82
|
+
* Fixed Issues
|
83
|
+
|
84
|
+
- Fix a bug that an array is always bound as null.
|
85
|
+
This bug was introduced in ruby-oci8 2.0.5.
|
86
|
+
(reported by Leoš Bitto)
|
87
|
+
|
88
|
+
- Avoid a gcc internal compiler error when using ruby1.9.2-p290 on
|
89
|
+
ubuntu 11.10 (64bit). (reported by Bob Saveland.)
|
90
|
+
|
91
|
+
- Fix compilation problems on Solaris.
|
92
|
+
(Reported by Sanjiv Patel.)
|
93
|
+
|
94
|
+
- Fix compilation problems on Linux.
|
95
|
+
(Reported by Edgars Beigarts.)
|
96
|
+
|
97
|
+
- Connections are released by GC without explicit logoff.
|
98
|
+
|
99
|
+
- Set ruby encoding CP950 for oracle characterset ZHT16MSWIN950 and
|
100
|
+
CP951 for ZHT16HKSCS and ZHT16HKSCS31 when the ruby is 1.9.3.
|
101
|
+
|
102
|
+
- Clear an executuing thread information in a connection when a SQL
|
103
|
+
executions is canceled by Thread#kill or Timeout::timeout.
|
104
|
+
(reported by Aaron Qian)
|
105
|
+
|
106
|
+
- Fix some test cases for object type and TZ issues.
|
107
|
+
(reported by Yasuo Honda)
|
108
|
+
|
109
|
+
- Use Gem::Command.build_args to get arguments after '--'.
|
110
|
+
(reported by jbirdjavi)
|
111
|
+
|
1
112
|
2.0.6:
|
2
113
|
|
3
114
|
* Fixed issues
|
data/README
CHANGED
@@ -1,86 +1,5 @@
|
|
1
|
-
|
1
|
+
Ruby-oci8 is a ruby interface for Oracle using OCI8 API.
|
2
|
+
The latest version (2.1.x) works with Oracle9i or later.
|
3
|
+
Use ruby-oci8 2.0.6 or earlier for Oracle 8.
|
2
4
|
|
3
|
-
|
4
|
-
* <tt>ruby</tt> is 1.8.0 or later? (Use ruby-oci8 0.1.x for ruby 1.6.x.)
|
5
|
-
|
6
|
-
== For OCI installed by Oracle Universal Installer
|
7
|
-
make sure the environment variable ORACLE_HOME (or registry on Windows)
|
8
|
-
is set correctly. run the the following commands.
|
9
|
-
|
10
|
-
make (or nmake on MSVC)
|
11
|
-
|
12
|
-
== For OCI installed by Oracle Instant Installer
|
13
|
-
|
14
|
-
linux:
|
15
|
-
ruby setup.rb config -- --with-instant-client
|
16
|
-
make
|
17
|
-
|
18
|
-
others:
|
19
|
-
ruby setup.rb config -- --with-instant-client=/path/to/instantclient10_1
|
20
|
-
make (or nmake on MSVC)
|
21
|
-
|
22
|
-
= On compilation failure
|
23
|
-
|
24
|
-
Please report the following information to kubo@jiubao.org.
|
25
|
-
|
26
|
-
* last 100 lines of 'ext/oci8/mkmf.log'.
|
27
|
-
* the results of the following commands:
|
28
|
-
ruby -r rbconfig -e "p Config::CONFIG['host']"
|
29
|
-
ruby -r rbconfig -e "p Config::CONFIG['CC']"
|
30
|
-
ruby -r rbconfig -e "p Config::CONFIG['CFLAGS']"
|
31
|
-
ruby -r rbconfig -e "p Config::CONFIG['LDSHARED']"
|
32
|
-
ruby -r rbconfig -e "p Config::CONFIG['LDFLAGS']"
|
33
|
-
ruby -r rbconfig -e "p Config::CONFIG['LIBS']"
|
34
|
-
ruby -r rbconfig -e "p Config::CONFIG['GNU_LD']"
|
35
|
-
* if you use gcc:
|
36
|
-
gcc --print-prog-name=ld
|
37
|
-
gcc --print-prog-name=as
|
38
|
-
* on platforms which can use both 32bit/64bit binaries:
|
39
|
-
file $ORACLE_HOME/bin/oracle
|
40
|
-
file `which ruby`
|
41
|
-
echo $LD_LIBRARY_PATH
|
42
|
-
|
43
|
-
= How to run unit test
|
44
|
-
|
45
|
-
before runing unit test,
|
46
|
-
1. connect to Oracle as system:
|
47
|
-
|
48
|
-
$ sqlplus system/<password_of_system>
|
49
|
-
|
50
|
-
2. create user ruby:
|
51
|
-
|
52
|
-
SQL> CREATE USER ruby IDENTIFIED BY oci8;
|
53
|
-
|
54
|
-
or
|
55
|
-
|
56
|
-
SQL> CREATE USER ruby IDENTIFIED BY oci8
|
57
|
-
2 DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
|
58
|
-
|
59
|
-
3. grant the privilege to connect and execute.
|
60
|
-
|
61
|
-
SQL> GRANT connect, resource TO ruby;
|
62
|
-
|
63
|
-
4. If the Oracle version is 8i or later:
|
64
|
-
|
65
|
-
SQL> CREATE TABLE ruby.test_clob (filename VARCHAR2(40), content CLOB);
|
66
|
-
|
67
|
-
5. connect to Oracle as sys
|
68
|
-
|
69
|
-
$ sqlplus 'sys/<password_of_sys> as sysdba'
|
70
|
-
|
71
|
-
6. grant the privilege for the unittest of blocking-mode.
|
72
|
-
|
73
|
-
SQL> GRANT EXECUTE ON dbms_lock TO ruby;
|
74
|
-
|
75
|
-
7. change test/config.rb as you like
|
76
|
-
|
77
|
-
Then you can run:
|
78
|
-
$ make check
|
79
|
-
or
|
80
|
-
$ nmake check (If your compiler is MS Visual C++.)
|
81
|
-
|
82
|
-
= TODO
|
83
|
-
|
84
|
-
* more proper handling of OCI_SUCCESS_WITH_INFO.
|
85
|
-
* more proper handling of NUMBER without its scale values.
|
86
|
-
* support Timestamp.
|
5
|
+
See: http://ruby-oci8.rubyforge.org
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
data/dist-files
CHANGED
@@ -21,12 +21,14 @@ ext/oci8/apiwrap.rb
|
|
21
21
|
ext/oci8/apiwrap.yml
|
22
22
|
ext/oci8/attr.c
|
23
23
|
ext/oci8/bind.c
|
24
|
+
ext/oci8/connection_pool.c
|
24
25
|
ext/oci8/encoding.c
|
25
26
|
ext/oci8/env.c
|
26
27
|
ext/oci8/error.c
|
27
28
|
ext/oci8/extconf.rb
|
28
29
|
ext/oci8/lob.c
|
29
30
|
ext/oci8/metadata.c
|
31
|
+
ext/oci8/object.c
|
30
32
|
ext/oci8/oci8.c
|
31
33
|
ext/oci8/oci8.h
|
32
34
|
ext/oci8/oci8lib.c
|
@@ -39,21 +41,23 @@ ext/oci8/oranumber_util.c
|
|
39
41
|
ext/oci8/oranumber_util.h
|
40
42
|
ext/oci8/post-config.rb
|
41
43
|
ext/oci8/stmt.c
|
42
|
-
ext/oci8/
|
44
|
+
ext/oci8/thread_util.c
|
45
|
+
ext/oci8/thread_util.h
|
43
46
|
ext/oci8/win32.c
|
44
|
-
ext/oci8/xmldb.c
|
45
47
|
lib/.document
|
46
48
|
lib/oci8.rb.in
|
47
49
|
lib/dbd/OCI8.rb
|
48
50
|
lib/oci8/.document
|
49
51
|
lib/oci8/bindtype.rb
|
50
52
|
lib/oci8/compat.rb
|
53
|
+
lib/oci8/connection_pool.rb
|
51
54
|
lib/oci8/datetime.rb
|
52
55
|
lib/oci8/encoding-init.rb
|
53
56
|
lib/oci8/encoding.yml
|
54
57
|
lib/oci8/metadata.rb
|
55
58
|
lib/oci8/object.rb
|
56
59
|
lib/oci8/oci8.rb
|
60
|
+
lib/oci8/ocihandle.rb
|
57
61
|
lib/oci8/oracle_version.rb
|
58
62
|
lib/oci8/properties.rb
|
59
63
|
test/README
|
@@ -62,14 +66,17 @@ test/test_all.rb
|
|
62
66
|
test/test_appinfo.rb
|
63
67
|
test/test_array_dml.rb
|
64
68
|
test/test_bind_raw.rb
|
69
|
+
test/test_bind_string.rb
|
65
70
|
test/test_bind_time.rb
|
66
71
|
test/test_break.rb
|
67
72
|
test/test_clob.rb
|
73
|
+
test/test_connection_pool.rb
|
68
74
|
test/test_connstr.rb
|
69
75
|
test/test_encoding.rb
|
70
76
|
test/test_datetime.rb
|
71
77
|
test/test_dbi.rb
|
72
78
|
test/test_dbi_clob.rb
|
79
|
+
test/test_error.rb
|
73
80
|
test/test_metadata.rb
|
74
81
|
test/test_oci8.rb
|
75
82
|
test/test_oracle_version.rb
|
data/lib/oci8.rb
CHANGED
@@ -6,16 +6,21 @@
|
|
6
6
|
# ruby -r oci8 -e 'OCI8.new("scott", "tiger", nil).exec("select * from emp") do |r| puts r.join(","); end'
|
7
7
|
# # select all data from emp and print them as CVS format.
|
8
8
|
|
9
|
+
ENV['ORA_SDTZ'] = ENV['TZ'] unless ENV['ORA_SDTZ']
|
10
|
+
|
9
11
|
if RUBY_PLATFORM =~ /cygwin/
|
10
12
|
# Cygwin manages environment variables by itself.
|
11
13
|
# They don't synchroize with Win32's ones.
|
12
14
|
# This set some Oracle's environment variables to win32's enviroment.
|
13
15
|
require 'Win32API'
|
14
16
|
win32setenv = Win32API.new('Kernel32.dll', 'SetEnvironmentVariableA', 'PP', 'I')
|
15
|
-
['NLS_LANG', '
|
17
|
+
['NLS_LANG', 'TNS_ADMIN', 'LOCAL'].each do |name|
|
16
18
|
val = ENV[name]
|
17
19
|
win32setenv.call(name, val && val.dup)
|
18
20
|
end
|
21
|
+
ENV.each do |name, val|
|
22
|
+
win32setenv.call(name, val && val.dup) if name =~ /^ORA/
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
so_basename = 'oci8lib_'
|
@@ -28,7 +33,7 @@ end
|
|
28
33
|
# 191 - ruby 1.9.1 and 1.9.2
|
29
34
|
# 19x - ruby 1.9.x future version which will break the API compatibility
|
30
35
|
case RUBY_VERSION
|
31
|
-
when /^1\.9/
|
36
|
+
when /^1\.9/, /^2\.0/
|
32
37
|
so_basename += '191'
|
33
38
|
when /^1\.8/
|
34
39
|
so_basename += '18'
|
@@ -37,14 +42,13 @@ else
|
|
37
42
|
end
|
38
43
|
require so_basename
|
39
44
|
|
40
|
-
if OCI8.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
load 'oci8/encoding-init.rb'
|
45
|
-
end
|
45
|
+
if OCI8::VERSION != '2.1.0'
|
46
|
+
require 'rbconfig'
|
47
|
+
so_name = so_basename + "." + Config::CONFIG['DLEXT']
|
48
|
+
raise "VERSION MISMATCH! #{so_name} version is #{OCI8::VERSION}, but oci8.rb version is 2.1.0."
|
46
49
|
end
|
47
50
|
|
51
|
+
require 'oci8/encoding-init.rb'
|
48
52
|
require 'oci8/oracle_version.rb'
|
49
53
|
|
50
54
|
class OCI8
|
@@ -77,17 +81,19 @@ class OCI8
|
|
77
81
|
def self.oracle_client_version
|
78
82
|
@@oracle_client_version
|
79
83
|
end
|
84
|
+
|
85
|
+
# defined for backward compatibility.
|
86
|
+
CLIENT_VERSION = @@oracle_client_version.major.to_s +
|
87
|
+
@@oracle_client_version.minor.to_s +
|
88
|
+
@@oracle_client_version.update.to_s
|
80
89
|
end
|
81
90
|
|
91
|
+
require 'oci8/ocihandle.rb'
|
82
92
|
require 'oci8/datetime.rb'
|
83
93
|
require 'oci8/oci8.rb'
|
84
94
|
require 'oci8/bindtype.rb'
|
85
95
|
require 'oci8/metadata.rb'
|
86
96
|
require 'oci8/compat.rb'
|
87
97
|
require 'oci8/object.rb'
|
98
|
+
require 'oci8/connection_pool.rb'
|
88
99
|
require 'oci8/properties.rb'
|
89
|
-
|
90
|
-
class OCI8
|
91
|
-
VERSION = '2.0.6'
|
92
|
-
CLIENT_VERSION = '1020'
|
93
|
-
end
|
data/lib/oci8.rb.in
CHANGED
@@ -6,16 +6,21 @@
|
|
6
6
|
# ruby -r oci8 -e 'OCI8.new("scott", "tiger", nil).exec("select * from emp") do |r| puts r.join(","); end'
|
7
7
|
# # select all data from emp and print them as CVS format.
|
8
8
|
|
9
|
+
ENV['ORA_SDTZ'] = ENV['TZ'] unless ENV['ORA_SDTZ']
|
10
|
+
|
9
11
|
if RUBY_PLATFORM =~ /cygwin/
|
10
12
|
# Cygwin manages environment variables by itself.
|
11
13
|
# They don't synchroize with Win32's ones.
|
12
14
|
# This set some Oracle's environment variables to win32's enviroment.
|
13
15
|
require 'Win32API'
|
14
16
|
win32setenv = Win32API.new('Kernel32.dll', 'SetEnvironmentVariableA', 'PP', 'I')
|
15
|
-
['NLS_LANG', '
|
17
|
+
['NLS_LANG', 'TNS_ADMIN', 'LOCAL'].each do |name|
|
16
18
|
val = ENV[name]
|
17
19
|
win32setenv.call(name, val && val.dup)
|
18
20
|
end
|
21
|
+
ENV.each do |name, val|
|
22
|
+
win32setenv.call(name, val && val.dup) if name =~ /^ORA/
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
so_basename = 'oci8lib_'
|
@@ -28,7 +33,7 @@ end
|
|
28
33
|
# 191 - ruby 1.9.1 and 1.9.2
|
29
34
|
# 19x - ruby 1.9.x future version which will break the API compatibility
|
30
35
|
case RUBY_VERSION
|
31
|
-
when /^1\.9/
|
36
|
+
when /^1\.9/, /^2\.0/
|
32
37
|
so_basename += '191'
|
33
38
|
when /^1\.8/
|
34
39
|
so_basename += '18'
|
@@ -37,14 +42,13 @@ else
|
|
37
42
|
end
|
38
43
|
require so_basename
|
39
44
|
|
40
|
-
if OCI8
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
load 'oci8/encoding-init.rb'
|
45
|
-
end
|
45
|
+
if OCI8::VERSION != '@@OCI8_MODULE_VERSION@@'
|
46
|
+
require 'rbconfig'
|
47
|
+
so_name = so_basename + "." + Config::CONFIG['DLEXT']
|
48
|
+
raise "VERSION MISMATCH! #{so_name} version is #{OCI8::VERSION}, but oci8.rb version is @@OCI8_MODULE_VERSION@@."
|
46
49
|
end
|
47
50
|
|
51
|
+
require 'oci8/encoding-init.rb'
|
48
52
|
require 'oci8/oracle_version.rb'
|
49
53
|
|
50
54
|
class OCI8
|
@@ -77,17 +81,19 @@ class OCI8
|
|
77
81
|
def self.oracle_client_version
|
78
82
|
@@oracle_client_version
|
79
83
|
end
|
84
|
+
|
85
|
+
# defined for backward compatibility.
|
86
|
+
CLIENT_VERSION = @@oracle_client_version.major.to_s +
|
87
|
+
@@oracle_client_version.minor.to_s +
|
88
|
+
@@oracle_client_version.update.to_s
|
80
89
|
end
|
81
90
|
|
91
|
+
require 'oci8/ocihandle.rb'
|
82
92
|
require 'oci8/datetime.rb'
|
83
93
|
require 'oci8/oci8.rb'
|
84
94
|
require 'oci8/bindtype.rb'
|
85
95
|
require 'oci8/metadata.rb'
|
86
96
|
require 'oci8/compat.rb'
|
87
97
|
require 'oci8/object.rb'
|
98
|
+
require 'oci8/connection_pool.rb'
|
88
99
|
require 'oci8/properties.rb'
|
89
|
-
|
90
|
-
class OCI8
|
91
|
-
VERSION = '@@OCI8_MODULE_VERSION@@'
|
92
|
-
CLIENT_VERSION = '@@OCI8_CLIENT_VERSION@@'
|
93
|
-
end
|
data/lib/oci8/.document
CHANGED
data/lib/oci8/bindtype.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# bindtype.rb -- OCI8::BindType
|
3
3
|
#
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2011 KUBO Takehiro <kubo@jiubao.org>
|
5
5
|
#++
|
6
6
|
|
7
7
|
class OCI8
|
@@ -105,45 +105,56 @@ class OCI8
|
|
105
105
|
def self.create(con, val, param, max_array_size)
|
106
106
|
case param
|
107
107
|
when Hash
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
108
|
+
param[:length_semantics] = OCI8::properties[:length_semantics] unless param.has_key? :length_semantics
|
109
|
+
unless param[:length]
|
110
|
+
if val.respond_to? :to_str
|
111
|
+
val = val.to_str
|
112
|
+
if param[:length_semantics] == :char
|
113
|
+
# character semantics
|
114
|
+
param[:length] = val.size
|
115
|
+
else
|
116
|
+
# byte semantics
|
117
|
+
if OCI8.respond_to? :encoding and OCI8.encoding != val.encoding
|
118
|
+
# If the string encoding is different with NLS_LANG character set,
|
119
|
+
# convert it to get the length.
|
120
|
+
val = val.encode(OCI8.encoding)
|
121
|
+
end
|
122
|
+
if val.respond_to? :bytesize
|
123
|
+
# ruby 1.8.7 or upper
|
124
|
+
param[:length] = val.bytesize
|
125
|
+
else
|
126
|
+
# ruby 1.8.6 or lower
|
127
|
+
param[:length] = val.size
|
128
|
+
end
|
129
|
+
end
|
120
130
|
else
|
121
|
-
|
122
|
-
length = val.size
|
131
|
+
param[:length] = @@minimum_bind_length
|
123
132
|
end
|
124
133
|
end
|
125
134
|
# use the default value when :nchar is not set explicitly.
|
126
|
-
nchar = OCI8.properties[:bind_string_as_nchar] unless param.has_key?(:nchar)
|
135
|
+
param[:nchar] = OCI8.properties[:bind_string_as_nchar] unless param.has_key?(:nchar)
|
127
136
|
when OCI8::Metadata::Base
|
128
137
|
case param.data_type
|
129
138
|
when :char, :varchar2
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
139
|
+
length_semantics = OCI8.properties[:length_semantics]
|
140
|
+
if length_semantics == :char
|
141
|
+
length = param.char_size
|
142
|
+
else
|
143
|
+
length = param.data_size * OCI8.nls_ratio
|
144
|
+
end
|
145
|
+
param = {
|
146
|
+
:length => length,
|
147
|
+
:length_semantics => length_semantics,
|
148
|
+
:nchar => (param.charset_form == :nchar),
|
149
|
+
}
|
136
150
|
when :raw
|
137
151
|
# HEX needs twice space.
|
138
|
-
|
152
|
+
param = {:length => param.data_size * 2}
|
153
|
+
else
|
154
|
+
param = {:length => @@minimum_bind_length}
|
139
155
|
end
|
140
156
|
end
|
141
|
-
|
142
|
-
if nchar
|
143
|
-
OCI8::BindType::NCHAR.new(con, val, length, max_array_size)
|
144
|
-
else
|
145
|
-
OCI8::BindType::CHAR.new(con, val, length, max_array_size)
|
146
|
-
end
|
157
|
+
self.new(con, val, param, max_array_size)
|
147
158
|
end
|
148
159
|
end
|
149
160
|
|
@@ -151,28 +162,36 @@ class OCI8
|
|
151
162
|
def self.create(con, val, param, max_array_size)
|
152
163
|
case param
|
153
164
|
when Hash
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
165
|
+
unless param[:length]
|
166
|
+
if val.respond_to? :to_str
|
167
|
+
val = val.to_str
|
168
|
+
if val.respond_to? :bytesize
|
169
|
+
param[:length] = val.bytesize
|
170
|
+
else
|
171
|
+
param[:length] = val.size
|
172
|
+
end
|
173
|
+
else
|
174
|
+
param[:length] = 400
|
175
|
+
end
|
159
176
|
end
|
160
177
|
when OCI8::Metadata::Base
|
161
|
-
|
178
|
+
param = {:length => param.data_size}
|
162
179
|
end
|
163
|
-
self.new(con, val,
|
180
|
+
self.new(con, val, param, max_array_size)
|
164
181
|
end
|
165
182
|
end
|
166
183
|
|
167
184
|
class Long < OCI8::BindType::String
|
168
185
|
def self.create(con, val, param, max_array_size)
|
169
|
-
|
186
|
+
param = {:length => con.long_read_len, :char_semantics => true}
|
187
|
+
super(con, val, param, max_array_size)
|
170
188
|
end
|
171
189
|
end
|
172
190
|
|
173
191
|
class LongRaw < OCI8::BindType::RAW
|
174
192
|
def self.create(con, val, param, max_array_size)
|
175
|
-
|
193
|
+
param = {:length => con.long_read_len, :char_semantics => false}
|
194
|
+
self.new(con, val, param, max_array_size)
|
176
195
|
end
|
177
196
|
end
|
178
197
|
|
@@ -260,13 +279,11 @@ OCI8::BindType::Mapping[:bfile] = OCI8::BindType::BFILE
|
|
260
279
|
# DATE SQLT_DAT 7 0 0
|
261
280
|
OCI8::BindType::Mapping[:date] = OCI8::BindType::Time
|
262
281
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
OCI8::BindType::Mapping[:interval_ds] = OCI8::BindType::IntervalDS
|
269
|
-
end
|
282
|
+
OCI8::BindType::Mapping[:timestamp] = OCI8::BindType::Time
|
283
|
+
OCI8::BindType::Mapping[:timestamp_tz] = OCI8::BindType::Time
|
284
|
+
OCI8::BindType::Mapping[:timestamp_ltz] = OCI8::BindType::Time
|
285
|
+
OCI8::BindType::Mapping[:interval_ym] = OCI8::BindType::IntervalYM
|
286
|
+
OCI8::BindType::Mapping[:interval_ds] = OCI8::BindType::IntervalDS
|
270
287
|
|
271
288
|
# datatype type size prec scale
|
272
289
|
# -------------------------------------------------
|