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 205
205:         def active?
206:           # Pings the connection to check if it's still good. Note that an
207:           # #active? method is also available, but that simply returns the 
208:           # last known state, which isn't good enough if the connection has
209:           # gone stale since the last use.
210:           @connection.ping
211:         rescue OCIException
212:           false
213:         end

Disconnects from the database.

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 223
223:         def disconnect!
224:           @connection.logoff rescue nil
225:           @connection.active = false
226:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 149
149:         def native_database_types #:nodoc
150:           {
151:             :primary_key => "NUMBER(38) NOT NULL PRIMARY KEY",
152:             :string      => { :name => "VARCHAR2", :limit => 255 },
153:             :text        => { :name => "CLOB" },
154:             :integer     => { :name => "NUMBER", :limit => 38 },
155:             :float       => { :name => "NUMBER" },
156:             :decimal     => { :name => "DECIMAL" },
157:             :datetime    => { :name => "DATE" },
158:             :timestamp   => { :name => "DATE" },
159:             :time        => { :name => "DATE" },
160:             :date        => { :name => "DATE" },
161:             :binary      => { :name => "BLOB" },
162:             :boolean     => { :name => "NUMBER", :limit => 1 }
163:           }
164:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 196
196:         def quoted_false
197:           "0"
198:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 192
192:         def quoted_true
193:           "1"
194:         end

Reconnects to the database.

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 216
216:         def reconnect!
217:           @connection.reset!
218:         rescue OCIException => e
219:           @logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}"
220:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 166
166:         def table_alias_length
167:           30
168:         end

[Validate]