106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/oci8/bindtype.rb', line 106
def self.create(con, val, param, max_array_size)
case param
when Hash
param[:length_semantics] = OCI8::properties[:length_semantics] unless param.has_key? :length_semantics
unless param[:length]
if val.respond_to? :to_str
val = val.to_str
if param[:length_semantics] == :char
param[:length] = val.size
else
if OCI8.encoding != val.encoding
val = val.encode(OCI8.encoding)
end
param[:length] = val.bytesize
end
else
param[:length] = @@minimum_bind_length
end
end
param[:nchar] = OCI8.properties[:bind_string_as_nchar] unless param.has_key?(:nchar)
when OCI8::Metadata::Base
case param.data_type
when :char, :varchar2
length_semantics = OCI8.properties[:length_semantics]
if length_semantics == :char
length = param.char_size
else
length = param.data_size * OCI8.nls_ratio
end
param = {
:length => length,
:length_semantics => length_semantics,
:nchar => (param.charset_form == :nchar),
}
when :raw
param = {:length => param.data_size * 2}
else
param = {:length => @@minimum_bind_length}
end
end
self.new(con, val, param, max_array_size)
end
|