Class ActiveRecord::ConnectionAdapters::OracleAdapter
In: vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb
Parent: AbstractAdapter

This is an Oracle/OCI adapter for the ActiveRecord persistence framework. It relies upon the OCI8 driver, which works with Oracle 8i and above. Most recent development has been on Debian Linux against a 10g database, ActiveRecord 1.12.1 and OCI8 0.1.13. See: rubyforge.org/projects/ruby-oci8/

Usage notes:

  • Key generation assumes a "${table_name}_seq" sequence is available for all tables; the sequence name can be changed using ActiveRecord::Base.set_sequence_name. When using Migrations, these sequences are created automatically.
  • Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently some hacks are employed to map data back to Date or Time in Ruby. If the column_name ends in _time it’s created as a Ruby Time. Else if the hours/minutes/seconds are 0, I make it a Ruby Date. Else it’s a Ruby Time. This is a bit nasty - but if you use Duck Typing you’ll probably not care very much. In 9i and up it’s tempting to map DATE to Date and TIMESTAMP to Time, but too many databases use DATE for both. Timezones and sub-second precision on timestamps are not supported.
  • Default values that are functions (such as "SYSDATE") are not supported. This is a restriction of the way ActiveRecord supports default values.
  • Support for Oracle8 is limited by Rails’ use of ANSI join syntax, which is supported in Oracle9i and later. You will need to use finder_sql for has_and_belongs_to_many associations to run against Oracle8.

Required parameters:

  • :username
  • :password
  • :database

Methods

External Aliases

execute -> update
execute -> delete

Public Instance methods

Returns true if the connection is active.

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 233
233:         def active?
234:           # Pings the connection to check if it's still good. Note that an
235:           # #active? method is also available, but that simply returns the 
236:           # last known state, which isn't good enough if the connection has
237:           # gone stale since the last use.
238:           @connection.ping
239:         rescue OCIException
240:           false
241:         end

Disconnects from the database.

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 251
251:         def disconnect!
252:           @connection.logoff rescue nil
253:           @connection.active = false
254:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 178
178:         def native_database_types #:nodoc
179:           {
180:             :primary_key => "NUMBER(38) NOT NULL PRIMARY KEY",
181:             :string      => { :name => "VARCHAR2", :limit => 255 },
182:             :text        => { :name => "CLOB" },
183:             :integer     => { :name => "NUMBER", :limit => 38 },
184:             :float       => { :name => "NUMBER" },
185:             :datetime    => { :name => "DATE" },
186:             :timestamp   => { :name => "DATE" },
187:             :time        => { :name => "DATE" },
188:             :date        => { :name => "DATE" },
189:             :binary      => { :name => "BLOB" },
190:             :boolean     => { :name => "NUMBER", :limit => 1 }
191:           }
192:         end

Reconnects to the database.

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 244
244:         def reconnect!
245:           @connection.reset!
246:         rescue OCIException => e
247:           @logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}"
248:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 194
194:         def table_alias_length
195:           30
196:         end

[Validate]