ruby-oci8 2.1.5.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +17 -0
- data/COPYING +30 -0
- data/COPYING_old +64 -0
- data/ChangeLog +2779 -0
- data/Makefile +92 -0
- data/NEWS +660 -0
- data/README.md +43 -0
- data/VERSION +1 -0
- data/dist-files +91 -0
- data/docs/install-binary-package.md +40 -0
- data/docs/install-full-client.md +116 -0
- data/docs/install-instant-client.md +167 -0
- data/docs/platform-specific-issues.md +197 -0
- data/docs/report-installation-issue.md +50 -0
- data/lib/.document +1 -0
- data/lib/dbd/OCI8.rb +591 -0
- data/lib/oci8.rb +147 -0
- data/lib/oci8.rb.in +147 -0
- data/lib/oci8/.document +8 -0
- data/lib/oci8/bindtype.rb +350 -0
- data/lib/oci8/compat.rb +113 -0
- data/lib/oci8/connection_pool.rb +108 -0
- data/lib/oci8/cursor.rb +564 -0
- data/lib/oci8/datetime.rb +605 -0
- data/lib/oci8/encoding-init.rb +79 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2092 -0
- data/lib/oci8/object.rb +605 -0
- data/lib/oci8/oci8.rb +560 -0
- data/lib/oci8/ocihandle.rb +607 -0
- data/lib/oci8/oracle_version.rb +143 -0
- data/lib/oci8/properties.rb +134 -0
- data/lib/oci8lib_200.so +0 -0
- data/metaconfig +142 -0
- data/pre-distclean.rb +7 -0
- data/ruby-oci8.gemspec +80 -0
- data/setup.rb +1333 -0
- data/test/README +42 -0
- data/test/config.rb +184 -0
- data/test/setup_test_object.sql +171 -0
- data/test/test_all.rb +54 -0
- data/test/test_appinfo.rb +63 -0
- data/test/test_array_dml.rb +333 -0
- data/test/test_bind_raw.rb +46 -0
- data/test/test_bind_string.rb +106 -0
- data/test/test_bind_time.rb +178 -0
- data/test/test_break.rb +124 -0
- data/test/test_clob.rb +98 -0
- data/test/test_connection_pool.rb +125 -0
- data/test/test_connstr.rb +81 -0
- data/test/test_datetime.rb +581 -0
- data/test/test_dbi.rb +366 -0
- data/test/test_dbi_clob.rb +53 -0
- data/test/test_encoding.rb +104 -0
- data/test/test_error.rb +88 -0
- data/test/test_metadata.rb +1485 -0
- data/test/test_object.rb +462 -0
- data/test/test_oci8.rb +489 -0
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +256 -0
- data/test/test_oranumber.rb +787 -0
- data/test/test_rowid.rb +33 -0
- metadata +109 -0
data/lib/oci8.rb
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
|
2
|
+
# --*- ruby -*--
|
3
|
+
# This is based on yoshidam's oracle.rb.
|
4
|
+
#
|
5
|
+
# sample one liner:
|
6
|
+
# ruby -r oci8 -e 'OCI8.new("scott", "tiger", nil).exec("select * from emp") do |r| puts r.join(","); end'
|
7
|
+
# # select all data from emp and print them as CVS format.
|
8
|
+
|
9
|
+
ENV['ORA_SDTZ'] = ENV['TZ'] unless ENV['ORA_SDTZ']
|
10
|
+
|
11
|
+
if RUBY_PLATFORM =~ /cygwin/
|
12
|
+
# Cygwin manages environment variables by itself.
|
13
|
+
# They don't synchroize with Win32's ones.
|
14
|
+
# This set some Oracle's environment variables to win32's enviroment.
|
15
|
+
require 'Win32API'
|
16
|
+
win32setenv = Win32API.new('Kernel32.dll', 'SetEnvironmentVariableA', 'PP', 'I')
|
17
|
+
['NLS_LANG', 'TNS_ADMIN', 'LOCAL'].each do |name|
|
18
|
+
val = ENV[name]
|
19
|
+
win32setenv.call(name, val && val.dup)
|
20
|
+
end
|
21
|
+
ENV.each do |name, val|
|
22
|
+
win32setenv.call(name, val && val.dup) if name =~ /^ORA/
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ruby_engine = (defined? RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
27
|
+
|
28
|
+
so_basename = 'oci8lib_'
|
29
|
+
case ruby_engine
|
30
|
+
when 'ruby'
|
31
|
+
# The extension library name includes the ruby ABI (application binary interface)
|
32
|
+
# version. It is for binary gems which contain more than one extension library
|
33
|
+
# and use correct one depending on the ABI version.
|
34
|
+
#
|
35
|
+
# ruby version | ABI version
|
36
|
+
# --------------+--------------
|
37
|
+
# 1.8.6 | 1.8
|
38
|
+
# 1.8.7 | 1.8
|
39
|
+
# --------------+--------------
|
40
|
+
# 1.9.0 | 1.9.0
|
41
|
+
# 1.9.1 | 1.9.1
|
42
|
+
# 1.9.2 | 1.9.1
|
43
|
+
# 1.9.3 | 1.9.1
|
44
|
+
# --------------+--------------
|
45
|
+
# 2.0.0 | 2.0.0
|
46
|
+
# 2.0.1 | 2.0.1 (See: [ruby-core:49578])
|
47
|
+
# ... | ...
|
48
|
+
#
|
49
|
+
# Note: The ruby ABI version is same with RbConfig::CONFIG['ruby_version']
|
50
|
+
# if it wasn't explicitly changed by the configure option --with-ruby-version.
|
51
|
+
#
|
52
|
+
case RUBY_VERSION
|
53
|
+
when /^2\.0/
|
54
|
+
so_basename += RUBY_VERSION.gsub(/\W/, '')
|
55
|
+
when /^1\.9\.0/
|
56
|
+
raise 'unsupported ruby version: 1.9.0'
|
57
|
+
when /^1\.9/
|
58
|
+
so_basename += '191'
|
59
|
+
when /^1\.8/
|
60
|
+
so_basename += '18'
|
61
|
+
else
|
62
|
+
raise 'unsupported ruby version: ' + RUBY_VERSION
|
63
|
+
end
|
64
|
+
when 'rbx'
|
65
|
+
# "rbx -X18" and "rbx -X19" use different C header files.
|
66
|
+
case RUBY_VERSION
|
67
|
+
when /^2\.0/
|
68
|
+
so_basename += 'rbx20'
|
69
|
+
when /^1\.9/
|
70
|
+
so_basename += 'rbx19'
|
71
|
+
when /^1\.8/
|
72
|
+
so_basename += 'rbx18'
|
73
|
+
else
|
74
|
+
raise 'unsupported language mode: ' + RUBY_VERSION
|
75
|
+
end
|
76
|
+
when 'jruby'
|
77
|
+
raise "Ruby-oci8 doesn't support jruby because its C extension support is in development in jruby 1.6 and deprecated in jruby 1.7."
|
78
|
+
else
|
79
|
+
raise 'unsupported ruby engine: ' + RUBY_ENGINE
|
80
|
+
end
|
81
|
+
require so_basename
|
82
|
+
|
83
|
+
if OCI8::VERSION != '2.1.5'
|
84
|
+
require 'rbconfig'
|
85
|
+
so_name = so_basename + "." + RbConfig::CONFIG['DLEXT']
|
86
|
+
raise "VERSION MISMATCH! #{so_name} version is #{OCI8::VERSION}, but oci8.rb version is 2.1.5."
|
87
|
+
end
|
88
|
+
|
89
|
+
require 'oci8/encoding-init.rb'
|
90
|
+
require 'oci8/oracle_version.rb'
|
91
|
+
|
92
|
+
class OCI8
|
93
|
+
# @private
|
94
|
+
ORAVER_8_0 = OCI8::OracleVersion.new(8, 0)
|
95
|
+
# @private
|
96
|
+
ORAVER_8_1 = OCI8::OracleVersion.new(8, 1)
|
97
|
+
# @private
|
98
|
+
ORAVER_9_0 = OCI8::OracleVersion.new(9, 0)
|
99
|
+
# @private
|
100
|
+
ORAVER_9_2 = OCI8::OracleVersion.new(9, 2)
|
101
|
+
# @private
|
102
|
+
ORAVER_10_1 = OCI8::OracleVersion.new(10, 1)
|
103
|
+
# @private
|
104
|
+
ORAVER_10_2 = OCI8::OracleVersion.new(10, 2)
|
105
|
+
# @private
|
106
|
+
ORAVER_11_1 = OCI8::OracleVersion.new(11, 1)
|
107
|
+
|
108
|
+
# @private
|
109
|
+
@@oracle_client_version = OCI8::OracleVersion.new(self.oracle_client_vernum)
|
110
|
+
|
111
|
+
# Returns an OCI8::OracleVersion of the Oracle client version.
|
112
|
+
#
|
113
|
+
# If this library is configured without '--with-runtime-check',
|
114
|
+
# and compiled for Oracle 10.1 or lower, the major and minor
|
115
|
+
# numbers are determined at compile-time. The rests are zeros.
|
116
|
+
#
|
117
|
+
# If this library is configured with '--with-runtime-check'
|
118
|
+
# and the runtime Oracle library is Oracle 10.1 or lower, the
|
119
|
+
# major and minor numbers are determined at run-time. The
|
120
|
+
# rests are zeros.
|
121
|
+
#
|
122
|
+
# Otherwise, it is the version retrieved from an OCI function
|
123
|
+
# OCIClientVersion().
|
124
|
+
#
|
125
|
+
# @return [OCI8::OracleVersion] Oracle client version
|
126
|
+
# @see OCI8#oracle_server_version
|
127
|
+
def self.oracle_client_version
|
128
|
+
@@oracle_client_version
|
129
|
+
end
|
130
|
+
|
131
|
+
# defined for backward compatibility.
|
132
|
+
# @private
|
133
|
+
CLIENT_VERSION = @@oracle_client_version.major.to_s +
|
134
|
+
@@oracle_client_version.minor.to_s +
|
135
|
+
@@oracle_client_version.update.to_s
|
136
|
+
end
|
137
|
+
|
138
|
+
require 'oci8/ocihandle.rb'
|
139
|
+
require 'oci8/datetime.rb'
|
140
|
+
require 'oci8/oci8.rb'
|
141
|
+
require 'oci8/cursor.rb'
|
142
|
+
require 'oci8/bindtype.rb'
|
143
|
+
require 'oci8/metadata.rb'
|
144
|
+
require 'oci8/compat.rb'
|
145
|
+
require 'oci8/object.rb'
|
146
|
+
require 'oci8/connection_pool.rb'
|
147
|
+
require 'oci8/properties.rb'
|
data/lib/oci8.rb.in
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
|
2
|
+
# --*- ruby -*--
|
3
|
+
# This is based on yoshidam's oracle.rb.
|
4
|
+
#
|
5
|
+
# sample one liner:
|
6
|
+
# ruby -r oci8 -e 'OCI8.new("scott", "tiger", nil).exec("select * from emp") do |r| puts r.join(","); end'
|
7
|
+
# # select all data from emp and print them as CVS format.
|
8
|
+
|
9
|
+
ENV['ORA_SDTZ'] = ENV['TZ'] unless ENV['ORA_SDTZ']
|
10
|
+
|
11
|
+
if RUBY_PLATFORM =~ /cygwin/
|
12
|
+
# Cygwin manages environment variables by itself.
|
13
|
+
# They don't synchroize with Win32's ones.
|
14
|
+
# This set some Oracle's environment variables to win32's enviroment.
|
15
|
+
require 'Win32API'
|
16
|
+
win32setenv = Win32API.new('Kernel32.dll', 'SetEnvironmentVariableA', 'PP', 'I')
|
17
|
+
['NLS_LANG', 'TNS_ADMIN', 'LOCAL'].each do |name|
|
18
|
+
val = ENV[name]
|
19
|
+
win32setenv.call(name, val && val.dup)
|
20
|
+
end
|
21
|
+
ENV.each do |name, val|
|
22
|
+
win32setenv.call(name, val && val.dup) if name =~ /^ORA/
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ruby_engine = (defined? RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
27
|
+
|
28
|
+
so_basename = 'oci8lib_'
|
29
|
+
case ruby_engine
|
30
|
+
when 'ruby'
|
31
|
+
# The extension library name includes the ruby ABI (application binary interface)
|
32
|
+
# version. It is for binary gems which contain more than one extension library
|
33
|
+
# and use correct one depending on the ABI version.
|
34
|
+
#
|
35
|
+
# ruby version | ABI version
|
36
|
+
# --------------+--------------
|
37
|
+
# 1.8.6 | 1.8
|
38
|
+
# 1.8.7 | 1.8
|
39
|
+
# --------------+--------------
|
40
|
+
# 1.9.0 | 1.9.0
|
41
|
+
# 1.9.1 | 1.9.1
|
42
|
+
# 1.9.2 | 1.9.1
|
43
|
+
# 1.9.3 | 1.9.1
|
44
|
+
# --------------+--------------
|
45
|
+
# 2.0.0 | 2.0.0
|
46
|
+
# 2.0.1 | 2.0.1 (See: [ruby-core:49578])
|
47
|
+
# ... | ...
|
48
|
+
#
|
49
|
+
# Note: The ruby ABI version is same with RbConfig::CONFIG['ruby_version']
|
50
|
+
# if it wasn't explicitly changed by the configure option --with-ruby-version.
|
51
|
+
#
|
52
|
+
case RUBY_VERSION
|
53
|
+
when /^2\.0/
|
54
|
+
so_basename += RUBY_VERSION.gsub(/\W/, '')
|
55
|
+
when /^1\.9\.0/
|
56
|
+
raise 'unsupported ruby version: 1.9.0'
|
57
|
+
when /^1\.9/
|
58
|
+
so_basename += '191'
|
59
|
+
when /^1\.8/
|
60
|
+
so_basename += '18'
|
61
|
+
else
|
62
|
+
raise 'unsupported ruby version: ' + RUBY_VERSION
|
63
|
+
end
|
64
|
+
when 'rbx'
|
65
|
+
# "rbx -X18" and "rbx -X19" use different C header files.
|
66
|
+
case RUBY_VERSION
|
67
|
+
when /^2\.0/
|
68
|
+
so_basename += 'rbx20'
|
69
|
+
when /^1\.9/
|
70
|
+
so_basename += 'rbx19'
|
71
|
+
when /^1\.8/
|
72
|
+
so_basename += 'rbx18'
|
73
|
+
else
|
74
|
+
raise 'unsupported language mode: ' + RUBY_VERSION
|
75
|
+
end
|
76
|
+
when 'jruby'
|
77
|
+
raise "Ruby-oci8 doesn't support jruby because its C extension support is in development in jruby 1.6 and deprecated in jruby 1.7."
|
78
|
+
else
|
79
|
+
raise 'unsupported ruby engine: ' + RUBY_ENGINE
|
80
|
+
end
|
81
|
+
require so_basename
|
82
|
+
|
83
|
+
if OCI8::VERSION != '@@OCI8_MODULE_VERSION@@'
|
84
|
+
require 'rbconfig'
|
85
|
+
so_name = so_basename + "." + RbConfig::CONFIG['DLEXT']
|
86
|
+
raise "VERSION MISMATCH! #{so_name} version is #{OCI8::VERSION}, but oci8.rb version is @@OCI8_MODULE_VERSION@@."
|
87
|
+
end
|
88
|
+
|
89
|
+
require 'oci8/encoding-init.rb'
|
90
|
+
require 'oci8/oracle_version.rb'
|
91
|
+
|
92
|
+
class OCI8
|
93
|
+
# @private
|
94
|
+
ORAVER_8_0 = OCI8::OracleVersion.new(8, 0)
|
95
|
+
# @private
|
96
|
+
ORAVER_8_1 = OCI8::OracleVersion.new(8, 1)
|
97
|
+
# @private
|
98
|
+
ORAVER_9_0 = OCI8::OracleVersion.new(9, 0)
|
99
|
+
# @private
|
100
|
+
ORAVER_9_2 = OCI8::OracleVersion.new(9, 2)
|
101
|
+
# @private
|
102
|
+
ORAVER_10_1 = OCI8::OracleVersion.new(10, 1)
|
103
|
+
# @private
|
104
|
+
ORAVER_10_2 = OCI8::OracleVersion.new(10, 2)
|
105
|
+
# @private
|
106
|
+
ORAVER_11_1 = OCI8::OracleVersion.new(11, 1)
|
107
|
+
|
108
|
+
# @private
|
109
|
+
@@oracle_client_version = OCI8::OracleVersion.new(self.oracle_client_vernum)
|
110
|
+
|
111
|
+
# Returns an OCI8::OracleVersion of the Oracle client version.
|
112
|
+
#
|
113
|
+
# If this library is configured without '--with-runtime-check',
|
114
|
+
# and compiled for Oracle 10.1 or lower, the major and minor
|
115
|
+
# numbers are determined at compile-time. The rests are zeros.
|
116
|
+
#
|
117
|
+
# If this library is configured with '--with-runtime-check'
|
118
|
+
# and the runtime Oracle library is Oracle 10.1 or lower, the
|
119
|
+
# major and minor numbers are determined at run-time. The
|
120
|
+
# rests are zeros.
|
121
|
+
#
|
122
|
+
# Otherwise, it is the version retrieved from an OCI function
|
123
|
+
# OCIClientVersion().
|
124
|
+
#
|
125
|
+
# @return [OCI8::OracleVersion] Oracle client version
|
126
|
+
# @see OCI8#oracle_server_version
|
127
|
+
def self.oracle_client_version
|
128
|
+
@@oracle_client_version
|
129
|
+
end
|
130
|
+
|
131
|
+
# defined for backward compatibility.
|
132
|
+
# @private
|
133
|
+
CLIENT_VERSION = @@oracle_client_version.major.to_s +
|
134
|
+
@@oracle_client_version.minor.to_s +
|
135
|
+
@@oracle_client_version.update.to_s
|
136
|
+
end
|
137
|
+
|
138
|
+
require 'oci8/ocihandle.rb'
|
139
|
+
require 'oci8/datetime.rb'
|
140
|
+
require 'oci8/oci8.rb'
|
141
|
+
require 'oci8/cursor.rb'
|
142
|
+
require 'oci8/bindtype.rb'
|
143
|
+
require 'oci8/metadata.rb'
|
144
|
+
require 'oci8/compat.rb'
|
145
|
+
require 'oci8/object.rb'
|
146
|
+
require 'oci8/connection_pool.rb'
|
147
|
+
require 'oci8/properties.rb'
|
data/lib/oci8/.document
ADDED
@@ -0,0 +1,350 @@
|
|
1
|
+
#--
|
2
|
+
# bindtype.rb -- OCI8::BindType
|
3
|
+
#
|
4
|
+
# Copyright (C) 2009-2011 KUBO Takehiro <kubo@jiubao.org>
|
5
|
+
#++
|
6
|
+
|
7
|
+
#
|
8
|
+
class OCI8
|
9
|
+
module BindType
|
10
|
+
Mapping = {}
|
11
|
+
|
12
|
+
class Base
|
13
|
+
def self.create(con, val, param, max_array_size)
|
14
|
+
self.new(con, val, param, max_array_size)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# get/set Date
|
19
|
+
class Date < OCI8::BindType::OraDate
|
20
|
+
def set(val)
|
21
|
+
super(val && ::OraDate.new(val.year, val.mon, val.mday))
|
22
|
+
end
|
23
|
+
def get()
|
24
|
+
(val = super()) && val.to_date
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class BigDecimal < OCI8::BindType::OraNumber
|
29
|
+
@@bigdecimal_is_required = false
|
30
|
+
def get()
|
31
|
+
unless @@bigdecimal_is_required
|
32
|
+
require 'bigdecimal'
|
33
|
+
@@bigdecimal_is_required = true
|
34
|
+
end
|
35
|
+
(val = super()) && val.to_d
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Rational < OCI8::BindType::OraNumber
|
40
|
+
@@rational_is_required = false
|
41
|
+
def get()
|
42
|
+
unless @@rational_is_required
|
43
|
+
require 'rational'
|
44
|
+
@@rational_is_required = true
|
45
|
+
end
|
46
|
+
(val = super()) && val.to_r
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class BasicNumberType < OCI8::BindType::OraNumber
|
51
|
+
def get()
|
52
|
+
(val = super()) && (val.has_decimal_part? ? val.to_f : val.to_i)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# get/set Number (for OCI8::SQLT_NUM)
|
57
|
+
class Number
|
58
|
+
def self.create(con, val, param, max_array_size)
|
59
|
+
if param.is_a? OCI8::Metadata::Base
|
60
|
+
precision = param.precision
|
61
|
+
scale = param.scale
|
62
|
+
end
|
63
|
+
if scale == -127
|
64
|
+
if precision == 0
|
65
|
+
# NUMBER declared without its scale and precision. (Oracle 9.2.0.3 or above)
|
66
|
+
klass = OCI8::BindType::Mapping[:number_no_prec_setting]
|
67
|
+
else
|
68
|
+
# FLOAT or FLOAT(p)
|
69
|
+
klass = OCI8::BindType::Float
|
70
|
+
end
|
71
|
+
elsif scale == 0
|
72
|
+
if precision == 0
|
73
|
+
# NUMBER whose scale and precision is unknown
|
74
|
+
# or
|
75
|
+
# NUMBER declared without its scale and precision. (Oracle 9.2.0.2 or below)
|
76
|
+
klass = OCI8::BindType::Mapping[:number_unknown_prec]
|
77
|
+
else
|
78
|
+
# NUMBER(p, 0)
|
79
|
+
klass = OCI8::BindType::Integer
|
80
|
+
end
|
81
|
+
else
|
82
|
+
# NUMBER(p, s)
|
83
|
+
if precision < 15 # the precision of double.
|
84
|
+
klass = OCI8::BindType::Float
|
85
|
+
else
|
86
|
+
# use BigDecimal instead
|
87
|
+
klass = OCI8::BindType::BigDecimal
|
88
|
+
end
|
89
|
+
end
|
90
|
+
klass.new(con, val, nil, max_array_size)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class String
|
95
|
+
# 1333 <= ceil(4000 / 3). 4000 is max size of char. 3 is NLS ratio of UTF-8.
|
96
|
+
@@minimum_bind_length = 1333
|
97
|
+
|
98
|
+
def self.minimum_bind_length
|
99
|
+
@@minimum_bind_length
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.minimum_bind_length=(val)
|
103
|
+
@@minimum_bind_length = val
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.create(con, val, param, max_array_size)
|
107
|
+
case param
|
108
|
+
when Hash
|
109
|
+
param[:length_semantics] = OCI8::properties[:length_semantics] unless param.has_key? :length_semantics
|
110
|
+
unless param[:length]
|
111
|
+
if val.respond_to? :to_str
|
112
|
+
val = val.to_str
|
113
|
+
if param[:length_semantics] == :char
|
114
|
+
# character semantics
|
115
|
+
param[:length] = val.size
|
116
|
+
else
|
117
|
+
# byte semantics
|
118
|
+
if OCI8.respond_to? :encoding and OCI8.encoding != val.encoding
|
119
|
+
# If the string encoding is different with NLS_LANG character set,
|
120
|
+
# convert it to get the length.
|
121
|
+
val = val.encode(OCI8.encoding)
|
122
|
+
end
|
123
|
+
if val.respond_to? :bytesize
|
124
|
+
# ruby 1.8.7 or upper
|
125
|
+
param[:length] = val.bytesize
|
126
|
+
else
|
127
|
+
# ruby 1.8.6 or lower
|
128
|
+
param[:length] = val.size
|
129
|
+
end
|
130
|
+
end
|
131
|
+
else
|
132
|
+
param[:length] = @@minimum_bind_length
|
133
|
+
end
|
134
|
+
end
|
135
|
+
# use the default value when :nchar is not set explicitly.
|
136
|
+
param[:nchar] = OCI8.properties[:bind_string_as_nchar] unless param.has_key?(:nchar)
|
137
|
+
when OCI8::Metadata::Base
|
138
|
+
case param.data_type
|
139
|
+
when :char, :varchar2
|
140
|
+
length_semantics = OCI8.properties[:length_semantics]
|
141
|
+
if length_semantics == :char
|
142
|
+
length = param.char_size
|
143
|
+
else
|
144
|
+
length = param.data_size * OCI8.nls_ratio
|
145
|
+
end
|
146
|
+
param = {
|
147
|
+
:length => length,
|
148
|
+
:length_semantics => length_semantics,
|
149
|
+
:nchar => (param.charset_form == :nchar),
|
150
|
+
}
|
151
|
+
when :raw
|
152
|
+
# HEX needs twice space.
|
153
|
+
param = {:length => param.data_size * 2}
|
154
|
+
else
|
155
|
+
param = {:length => @@minimum_bind_length}
|
156
|
+
end
|
157
|
+
end
|
158
|
+
self.new(con, val, param, max_array_size)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
class RAW
|
163
|
+
def self.create(con, val, param, max_array_size)
|
164
|
+
case param
|
165
|
+
when Hash
|
166
|
+
unless param[:length]
|
167
|
+
if val.respond_to? :to_str
|
168
|
+
val = val.to_str
|
169
|
+
if val.respond_to? :bytesize
|
170
|
+
param[:length] = val.bytesize
|
171
|
+
else
|
172
|
+
param[:length] = val.size
|
173
|
+
end
|
174
|
+
else
|
175
|
+
param[:length] = 400
|
176
|
+
end
|
177
|
+
end
|
178
|
+
when OCI8::Metadata::Base
|
179
|
+
param = {:length => param.data_size}
|
180
|
+
end
|
181
|
+
self.new(con, val, param, max_array_size)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
class Long < OCI8::BindType::String
|
186
|
+
def self.create(con, val, param, max_array_size)
|
187
|
+
param = {:length => con.long_read_len, :char_semantics => true}
|
188
|
+
super(con, val, param, max_array_size)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
class LongRaw < OCI8::BindType::RAW
|
193
|
+
def self.create(con, val, param, max_array_size)
|
194
|
+
param = {:length => con.long_read_len, :char_semantics => false}
|
195
|
+
self.new(con, val, param, max_array_size)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
class CLOB
|
200
|
+
def self.create(con, val, param, max_array_size)
|
201
|
+
if param.is_a? OCI8::Metadata::Base and param.charset_form == :nchar
|
202
|
+
OCI8::BindType::NCLOB.new(con, val, nil, max_array_size)
|
203
|
+
else
|
204
|
+
OCI8::BindType::CLOB.new(con, val, nil, max_array_size)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end # BindType
|
209
|
+
end
|
210
|
+
|
211
|
+
# bind or explicitly define
|
212
|
+
OCI8::BindType::Mapping[String] = OCI8::BindType::String
|
213
|
+
OCI8::BindType::Mapping[OraNumber] = OCI8::BindType::OraNumber
|
214
|
+
OCI8::BindType::Mapping['BigDecimal'] = OCI8::BindType::BigDecimal
|
215
|
+
OCI8::BindType::Mapping['Rational'] = OCI8::BindType::Rational
|
216
|
+
OCI8::BindType::Mapping[Fixnum] = OCI8::BindType::Integer
|
217
|
+
OCI8::BindType::Mapping[Float] = OCI8::BindType::Float
|
218
|
+
OCI8::BindType::Mapping[Integer] = OCI8::BindType::Integer
|
219
|
+
OCI8::BindType::Mapping[Bignum] = OCI8::BindType::Integer
|
220
|
+
OCI8::BindType::Mapping[OraDate] = OCI8::BindType::OraDate
|
221
|
+
OCI8::BindType::Mapping[Time] = OCI8::BindType::Time
|
222
|
+
OCI8::BindType::Mapping[Date] = OCI8::BindType::Date
|
223
|
+
OCI8::BindType::Mapping[DateTime] = OCI8::BindType::DateTime
|
224
|
+
OCI8::BindType::Mapping[OCI8::CLOB] = OCI8::BindType::CLOB
|
225
|
+
OCI8::BindType::Mapping[OCI8::NCLOB] = OCI8::BindType::NCLOB
|
226
|
+
OCI8::BindType::Mapping[OCI8::BLOB] = OCI8::BindType::BLOB
|
227
|
+
OCI8::BindType::Mapping[OCI8::BFILE] = OCI8::BindType::BFILE
|
228
|
+
OCI8::BindType::Mapping[OCI8::Cursor] = OCI8::BindType::Cursor
|
229
|
+
|
230
|
+
# implicitly define
|
231
|
+
|
232
|
+
# datatype type size prec scale
|
233
|
+
# -------------------------------------------------
|
234
|
+
# CHAR(1) SQLT_AFC 1 0 0
|
235
|
+
# CHAR(10) SQLT_AFC 10 0 0
|
236
|
+
OCI8::BindType::Mapping[:char] = OCI8::BindType::String
|
237
|
+
|
238
|
+
# datatype type size prec scale
|
239
|
+
# -------------------------------------------------
|
240
|
+
# VARCHAR(1) SQLT_CHR 1 0 0
|
241
|
+
# VARCHAR(10) SQLT_CHR 10 0 0
|
242
|
+
# VARCHAR2(1) SQLT_CHR 1 0 0
|
243
|
+
# VARCHAR2(10) SQLT_CHR 10 0 0
|
244
|
+
OCI8::BindType::Mapping[:varchar2] = OCI8::BindType::String
|
245
|
+
|
246
|
+
# datatype type size prec scale
|
247
|
+
# -------------------------------------------------
|
248
|
+
# RAW(1) SQLT_BIN 1 0 0
|
249
|
+
# RAW(10) SQLT_BIN 10 0 0
|
250
|
+
OCI8::BindType::Mapping[:raw] = OCI8::BindType::RAW
|
251
|
+
|
252
|
+
# datatype type size prec scale
|
253
|
+
# -------------------------------------------------
|
254
|
+
# LONG SQLT_LNG 0 0 0
|
255
|
+
OCI8::BindType::Mapping[:long] = OCI8::BindType::Long
|
256
|
+
|
257
|
+
# datatype type size prec scale
|
258
|
+
# -------------------------------------------------
|
259
|
+
# LONG RAW SQLT_LBI 0 0 0
|
260
|
+
OCI8::BindType::Mapping[:long_raw] = OCI8::BindType::LongRaw
|
261
|
+
|
262
|
+
# datatype type size prec scale
|
263
|
+
# -------------------------------------------------
|
264
|
+
# CLOB SQLT_CLOB 4000 0 0
|
265
|
+
OCI8::BindType::Mapping[:clob] = OCI8::BindType::CLOB
|
266
|
+
OCI8::BindType::Mapping[:nclob] = OCI8::BindType::NCLOB
|
267
|
+
|
268
|
+
# datatype type size prec scale
|
269
|
+
# -------------------------------------------------
|
270
|
+
# BLOB SQLT_BLOB 4000 0 0
|
271
|
+
OCI8::BindType::Mapping[:blob] = OCI8::BindType::BLOB
|
272
|
+
|
273
|
+
# datatype type size prec scale
|
274
|
+
# -------------------------------------------------
|
275
|
+
# BFILE SQLT_BFILE 4000 0 0
|
276
|
+
OCI8::BindType::Mapping[:bfile] = OCI8::BindType::BFILE
|
277
|
+
|
278
|
+
# datatype type size prec scale
|
279
|
+
# -------------------------------------------------
|
280
|
+
# DATE SQLT_DAT 7 0 0
|
281
|
+
OCI8::BindType::Mapping[:date] = OCI8::BindType::Time
|
282
|
+
|
283
|
+
OCI8::BindType::Mapping[:timestamp] = OCI8::BindType::Time
|
284
|
+
OCI8::BindType::Mapping[:timestamp_tz] = OCI8::BindType::Time
|
285
|
+
OCI8::BindType::Mapping[:timestamp_ltz] = OCI8::BindType::Time
|
286
|
+
OCI8::BindType::Mapping[:interval_ym] = OCI8::BindType::IntervalYM
|
287
|
+
OCI8::BindType::Mapping[:interval_ds] = OCI8::BindType::IntervalDS
|
288
|
+
|
289
|
+
# datatype type size prec scale
|
290
|
+
# -------------------------------------------------
|
291
|
+
# ROWID SQLT_RDD 4 0 0
|
292
|
+
OCI8::BindType::Mapping[:rowid] = OCI8::BindType::String
|
293
|
+
|
294
|
+
# datatype type size prec scale
|
295
|
+
# -----------------------------------------------------
|
296
|
+
# FLOAT SQLT_NUM 22 126 -127
|
297
|
+
# FLOAT(1) SQLT_NUM 22 1 -127
|
298
|
+
# FLOAT(126) SQLT_NUM 22 126 -127
|
299
|
+
# DOUBLE PRECISION SQLT_NUM 22 126 -127
|
300
|
+
# REAL SQLT_NUM 22 63 -127
|
301
|
+
# NUMBER SQLT_NUM 22 0 0
|
302
|
+
# NUMBER(1) SQLT_NUM 22 1 0
|
303
|
+
# NUMBER(38) SQLT_NUM 22 38 0
|
304
|
+
# NUMBER(1, 0) SQLT_NUM 22 1 0
|
305
|
+
# NUMBER(38, 0) SQLT_NUM 22 38 0
|
306
|
+
# NUMERIC SQLT_NUM 22 38 0
|
307
|
+
# INT SQLT_NUM 22 38 0
|
308
|
+
# INTEGER SQLT_NUM 22 38 0
|
309
|
+
# SMALLINT SQLT_NUM 22 38 0
|
310
|
+
OCI8::BindType::Mapping[:number] = OCI8::BindType::Number
|
311
|
+
|
312
|
+
# mapping for calculated number values.
|
313
|
+
#
|
314
|
+
# for example:
|
315
|
+
# select col1 * 1.1 from tab1;
|
316
|
+
#
|
317
|
+
# For Oracle 9.2.0.2 or below, this is also used for NUMBER
|
318
|
+
# datatypes that have no explicit setting of their precision
|
319
|
+
# and scale.
|
320
|
+
#
|
321
|
+
# The default mapping is Float for ruby-oci8 1.0, OraNumber for 2.0.0 ~ 2.0.2,
|
322
|
+
# BigDecimal for 2.0.3 ~.
|
323
|
+
OCI8::BindType::Mapping[:number_unknown_prec] = OCI8::BindType::BigDecimal
|
324
|
+
|
325
|
+
# mapping for number without precision and scale.
|
326
|
+
#
|
327
|
+
# for example:
|
328
|
+
# create table tab1 (col1 number);
|
329
|
+
# select col1 from tab1;
|
330
|
+
#
|
331
|
+
# note: This is available only on Oracle 9.2.0.3 or above.
|
332
|
+
# see: Oracle 9.2.0.x Patch Set Notes.
|
333
|
+
#
|
334
|
+
# The default mapping is Float for ruby-oci8 1.0, OraNumber for 2.0.0 ~ 2.0.2,
|
335
|
+
# BigDecimal for 2.0.3 ~.
|
336
|
+
OCI8::BindType::Mapping[:number_no_prec_setting] = OCI8::BindType::BigDecimal
|
337
|
+
|
338
|
+
if defined? OCI8::BindType::BinaryDouble
|
339
|
+
OCI8::BindType::Mapping[:binary_float] = OCI8::BindType::BinaryDouble
|
340
|
+
OCI8::BindType::Mapping[:binary_double] = OCI8::BindType::BinaryDouble
|
341
|
+
else
|
342
|
+
OCI8::BindType::Mapping[:binary_float] = OCI8::BindType::Float
|
343
|
+
OCI8::BindType::Mapping[:binary_double] = OCI8::BindType::Float
|
344
|
+
end
|
345
|
+
|
346
|
+
# Cursor
|
347
|
+
OCI8::BindType::Mapping[:cursor] = OCI8::BindType::Cursor
|
348
|
+
|
349
|
+
# XMLType (This mapping will be changed before release.)
|
350
|
+
OCI8::BindType::Mapping[:xmltype] = OCI8::BindType::Long
|