class ActiveRecord::ConnectionAdapters::OracleEnhanced::JDBCConnection::Cursor
Public Class Methods
new(connection, raw_statement)
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 297 def initialize(connection, raw_statement) @connection = connection @raw_statement = raw_statement end
Public Instance Methods
bind_param(position, value)
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 314 def bind_param(position, value) case value when Integer @raw_statement.setLong(position, value) when Float @raw_statement.setFloat(position, value) when BigDecimal @raw_statement.setBigDecimal(position, value) when Java::OracleSql::BLOB @raw_statement.setBlob(position, value) when Java::OracleSql::CLOB @raw_statement.setClob(position, value) when Java::OracleSql::NCLOB @raw_statement.setClob(position, value) when Type::OracleEnhanced::Raw @raw_statement.setString(position, OracleEnhanced::Quoting.encode_raw(value)) when Type::OracleEnhanced::CharacterString::Data @raw_statement.setFixedCHAR(position, value.to_s) when String @raw_statement.setString(position, value) when Java::OracleSql::DATE @raw_statement.setDATE(position, value) when Java::JavaSql::Timestamp @raw_statement.setTimestamp(position, value) when Time new_value = Java::java.sql.Timestamp.new(value.year - 1900, value.month - 1, value.day, value.hour, value.min, value.sec, value.usec * 1000) @raw_statement.setTimestamp(position, new_value) when NilClass # TODO: currently nil is always bound as NULL with VARCHAR type. # When nils will actually be used by ActiveRecord as bound parameters # then need to pass actual column type. @raw_statement.setNull(position, java.sql.Types::VARCHAR) else raise ArgumentError, "Don't know how to bind variable with type #{value.class}" end end
bind_params(*bind_vars)
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 302 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)
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 351 def bind_returning_param(position, bind_type) @returning_positions ||= [] @returning_positions << position if bind_type == Integer @raw_statement.registerReturnParameter(position, java.sql.Types::BIGINT) end end
close()
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 408 def close @raw_statement.close end
column_names()
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 376 def column_names @column_names ||= (1..metadata.getColumnCount).map { |i| metadata.getColumnName(i) } end
Also aliased as: get_col_names
column_types()
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 372 def column_types @column_types ||= (1..metadata.getColumnCount).map { |i| metadata.getColumnTypeName(i).to_sym } end
exec()
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 359 def exec @raw_result_set = @raw_statement.executeQuery true end
exec_update()
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 364 def exec_update @raw_statement.executeUpdate end
fetch(options = {})
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 381 def fetch(options = {}) if @raw_result_set.next get_lob_value = options[:get_lob_value] row_values = [] column_types.each_with_index do |column_type, i| row_values << @connection.get_ruby_value_from_result_set(@raw_result_set, i + 1, column_type, get_lob_value) end row_values else @raw_result_set.close nil end end
get_returning_param(position, type)
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 396 def get_returning_param(position, type) rs_position = @returning_positions.index(position) + 1 rs = @raw_statement.getReturnResultSet if rs.next # Assuming that primary key will not be larger as long max value returning_id = rs.getLong(rs_position) rs.wasNull ? nil : returning_id else nil end end
metadata()
click to toggle source
# File lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb, line 368 def metadata @metadata ||= @raw_result_set.getMetaData end