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
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 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/oci8/bindtype.rb', line 105 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 # use the default value when :nchar is not set explicitly. nchar = OCI8.properties[:bind_string_as_nchar] unless param.has_key?(:nchar) 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? nchar = (param.charset_form == :nchar) 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 if nchar OCI8::BindType::NCHAR.new(con, val, length, max_array_size) else OCI8::BindType::CHAR.new(con, val, length, max_array_size) end end |
.minimum_bind_length ⇒ Object
97 98 99 |
# File 'lib/oci8/bindtype.rb', line 97 def self.minimum_bind_length @@minimum_bind_length end |
.minimum_bind_length=(val) ⇒ Object
101 102 103 |
# File 'lib/oci8/bindtype.rb', line 101 def self.minimum_bind_length=(val) @@minimum_bind_length = val end |