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, col_type = 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.
111 112 113 114 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 111 def initialize(connection, raw_cursor) @connection = connection @raw_cursor = raw_cursor end |
Instance Method Details
#bind_param(position, value, col_type = nil) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 116 def bind_param(position, value, col_type = nil) if value.nil? @raw_cursor.bind_param(position, nil, String) else case col_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
138 139 140 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 138 def bind_returning_param(position, bind_type) @raw_cursor.bind_param(position, nil, bind_type) end |
#close ⇒ Object
167 168 169 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 167 def close @raw_cursor.close end |
#exec ⇒ Object
142 143 144 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 142 def exec @raw_cursor.exec end |
#exec_update ⇒ Object
146 147 148 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 146 def exec_update @raw_cursor.exec end |
#fetch(options = {}) ⇒ Object
154 155 156 157 158 159 160 161 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 154 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
150 151 152 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 150 def get_col_names @raw_cursor.get_col_names end |
#get_returning_param(position, type) ⇒ Object
163 164 165 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb', line 163 def get_returning_param(position, type) @raw_cursor[position] end |