Class: ActiveRecord::ConnectionAdapters::OracleEnhanced::OCIConnection::Cursor

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, raw_cursor) ⇒ Cursor

Returns a new instance of Cursor.



113
114
115
116
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 113

def initialize(connection, raw_cursor)
  @raw_connection = connection
  @raw_cursor = raw_cursor
end

Instance Method Details

#bind_param(position, value) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 130

def bind_param(position, value)
  case value
  when Type::OracleEnhanced::Raw
    @raw_cursor.bind_param(position, OracleEnhanced::Quoting.encode_raw(value))
  when ActiveModel::Type::Decimal
    @raw_cursor.bind_param(position, BigDecimal(value.to_s))
  when Type::OracleEnhanced::CharacterString::Data
    @raw_cursor.bind_param(position, value.to_character_str)
  when NilClass
    @raw_cursor.bind_param(position, nil, String)
  else
    @raw_cursor.bind_param(position, value)
  end
end

#bind_params(*bind_vars) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 118

def bind_params(*bind_vars)
  index = 1
  bind_vars.flatten.each do |var|
    if Hash === var
      var.each { |key, val| bind_param key, val }
    else
      bind_param index, var
      index += 1
    end
  end
end

#bind_returning_param(position, bind_type) ⇒ Object



145
146
147
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 145

def bind_returning_param(position, bind_type)
  @raw_cursor.bind_param(position, nil, bind_type)
end

#closeObject



185
186
187
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 185

def close
  @raw_cursor.close
end

#execObject



149
150
151
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 149

def exec
  @raw_cursor.exec
end

#exec_updateObject



153
154
155
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 153

def exec_update
  @raw_cursor.exec
end

#fetch(options = {}) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 161

def fetch(options = {})
  if row = @raw_cursor.fetch
    get_lob_value = options[:get_lob_value]
    col_index = 0
    row.map do |col|
      col_value = @raw_connection.typecast_result_value(col, get_lob_value)
       = @raw_cursor..fetch(col_index)
      if !.nil?
        key = .data_type
        case key.to_s.downcase
        when "char"
          col_value = col.to_s.rstrip
        end
      end
      col_index = col_index + 1
      col_value
    end
  end
end

#get_col_namesObject



157
158
159
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 157

def get_col_names
  @raw_cursor.get_col_names
end

#get_returning_param(position, type) ⇒ Object



181
182
183
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 181

def get_returning_param(position, type)
  @raw_cursor[position]
end