190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 190
def select(sql, name = nil, return_column_names = false)
cursor = @raw_connection.exec(sql)
cols = []
cursor.get_col_names.each do |col_name|
col_name = _oracle_downcase(col_name)
cols << col_name unless col_name == "raw_rnum_"
end
column_hash = {}
cols.each { |c| column_hash[c] = nil }
rows = []
get_lob_value = !(name == "Writable Large Object")
while row = cursor.fetch
hash = column_hash.dup
cols.each_with_index do |col, i|
col_value = typecast_result_value(row[i], get_lob_value)
col_metadata = cursor.column_metadata.fetch(i)
if !col_metadata.nil?
key = col_metadata.data_type
case key.to_s.downcase
when "char"
col_value = col_value.to_s.rstrip
end
end
hash[col] = col_value
end
rows << hash
end
return_column_names ? [rows, cols] : rows
ensure
cursor.close if cursor
end
|