Class: ActiveRecord::ConnectionAdapters::OracleEnhancedOCIConnection::Cursor
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::OracleEnhancedOCIConnection::Cursor
- Defined in:
- lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb
Instance Method Summary collapse
- #bind_param(position, value, column = nil) ⇒ Object
- #bind_returning_param(position, bind_type) ⇒ Object
- #close ⇒ Object
- #exec ⇒ Object
- #exec_update ⇒ Object
- #fetch(options = {}) ⇒ Object
- #get_col_names ⇒ Object
- #get_returning_param(position, type) ⇒ Object
-
#initialize(connection, raw_cursor) ⇒ Cursor
constructor
A new instance of Cursor.
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) @connection = connection @raw_cursor = raw_cursor end |
Instance Method Details
#bind_param(position, value, column = nil) ⇒ Object
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 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 118 def bind_param(position, value, column = nil) if column && column.object_type? if @connection.raw_connection.respond_to? :get_tdo_by_typename @raw_cursor.bind_param(position, value, :named_type, column.sql_type) else raise "Use ruby-oci8 2.1.6 or later to bind Oracle objects." end elsif value.nil? @raw_cursor.bind_param(position, nil, String) else case col_type = column && column.type when :text, :binary # ruby-oci8 cannot create CLOB/BLOB from '' lob_value = value == '' ? ' ' : value bind_type = col_type == :text ? OCI8::CLOB : OCI8::BLOB ora_value = bind_type.new(@connection.raw_oci_connection, lob_value) ora_value.size = 0 if value == '' @raw_cursor.bind_param(position, ora_value) when :raw @raw_cursor.bind_param(position, OracleEnhancedAdapter.encode_raw(value)) when :decimal @raw_cursor.bind_param(position, BigDecimal.new(value.to_s)) else @raw_cursor.bind_param(position, value) end end end |
#bind_returning_param(position, bind_type) ⇒ Object
146 147 148 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 146 def bind_returning_param(position, bind_type) @raw_cursor.bind_param(position, nil, bind_type) end |
#close ⇒ Object
175 176 177 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 175 def close @raw_cursor.close end |
#exec ⇒ Object
150 151 152 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 150 def exec @raw_cursor.exec end |
#exec_update ⇒ Object
154 155 156 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 154 def exec_update @raw_cursor.exec end |
#fetch(options = {}) ⇒ Object
162 163 164 165 166 167 168 169 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 162 def fetch(={}) if row = @raw_cursor.fetch get_lob_value = [:get_lob_value] row.map do |col| @connection.typecast_result_value(col, get_lob_value) end end end |
#get_col_names ⇒ Object
158 159 160 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 158 def get_col_names @raw_cursor.get_col_names end |
#get_returning_param(position, type) ⇒ Object
171 172 173 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 171 def get_returning_param(position, type) @raw_cursor[position] end |