Class: OCI8::BindType::String
Direct Known Subclasses
Constant Summary collapse
- @@minimum_bind_length =
1333 <= ceil(4000 / 3). 4000 is max size of char. 3 is NLS ratio of UTF-8.
1333
Class Method Summary collapse
- .create(con, val, param, max_array_size) ⇒ Object
- .minimum_bind_length ⇒ Object
- .minimum_bind_length=(val) ⇒ Object
Class Method Details
.create(con, val, param, max_array_size) ⇒ Object
99 100 101 102 103 104 105 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 |
# File 'lib/oci8/bindtype.rb', line 99 def self.create(con, val, param, max_array_size) case param when Hash if param[:length] # If length is passed explicitly, use it. length = param[:length] elsif val.is_a? String or (val.respond_to? :to_str and val = val.to_str) if OCI8.respond_to? :encoding and OCI8.encoding != val.encoding # If the string encoding is different with NLS_LANG character set, # convert it to get the length. val = val.encode(OCI8.encoding) end if val.respond_to? :bytesize # ruby 1.8.7 or upper length = val.bytesize else # ruby 1.8.6 or lower length = val.size end end when OCI8::Metadata::Base case param.data_type when :char, :varchar2 length = param.data_size # character size may become large on character set conversion. # The length of a Japanese half-width kana is one in Shift_JIS, # two in EUC-JP, three in UTF-8. length *= 3 unless param.char_used? when :raw # HEX needs twice space. length = param.data_size * 2 end end length = @@minimum_bind_length if length.nil? or length < @@minimum_bind_length self.new(con, val, length, max_array_size) end |
.minimum_bind_length ⇒ Object
91 92 93 |
# File 'lib/oci8/bindtype.rb', line 91 def self.minimum_bind_length @@minimum_bind_length end |
.minimum_bind_length=(val) ⇒ Object
95 96 97 |
# File 'lib/oci8/bindtype.rb', line 95 def self.minimum_bind_length=(val) @@minimum_bind_length = val end |