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.
115 116 117 118 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 115 def initialize(connection, raw_cursor) @connection = connection @raw_cursor = raw_cursor end |
Instance Method Details
#bind_param(position, value, column = nil) ⇒ Object
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 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 120 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
148 149 150 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 148 def bind_returning_param(position, bind_type) @raw_cursor.bind_param(position, nil, bind_type) end |
#close ⇒ Object
177 178 179 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 177 def close @raw_cursor.close end |
#exec ⇒ Object
152 153 154 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 152 def exec @raw_cursor.exec end |
#exec_update ⇒ Object
156 157 158 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 156 def exec_update @raw_cursor.exec end |
#fetch(options = {}) ⇒ Object
164 165 166 167 168 169 170 171 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 164 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
160 161 162 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 160 def get_col_names @raw_cursor.get_col_names end |
#get_returning_param(position, type) ⇒ Object
173 174 175 |
# File 'lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb', line 173 def get_returning_param(position, type) @raw_cursor[position] end |