Class | Sequel::Oracle::Database |
In: |
lib/sequel/adapters/oracle.rb
|
Parent: | Sequel::Database |
CONNECTION_ERROR_CODES | = | [ 28, 1012, 3113, 3114 ] | ORA-00028: your session has been killed ORA-01012: not logged on ORA-03113: end-of-file on communication channel ORA-03114: not connected to ORACLE | |
ORACLE_TYPES | = | {:blob=>lambda{|b| Sequel::SQL::Blob.new(b.read)}} | ||
PS_TYPES | = | {'string'.freeze=>String, 'integer'.freeze=>Integer, 'float'.freeze=>Float, 'decimal'.freeze=>Float, 'date'.freeze=>Time, 'datetime'.freeze=>Time, 'time'.freeze=>Time, 'boolean'.freeze=>String, 'blob'.freeze=>OCI8::BLOB} |
conversion_procs | [R] | Hash of conversion procs for this database. |
# File lib/sequel/adapters/oracle.rb, line 21 21: def initialize(opts={}) 22: super 23: @autosequence = opts[:autosequence] 24: @primary_key_sequences = {} 25: @conversion_procs = ORACLE_TYPES.dup 26: end
# File lib/sequel/adapters/oracle.rb, line 28 28: def connect(server) 29: opts = server_opts(server) 30: if opts[:database] 31: dbname = opts[:host] ? \ 32: "//#{opts[:host]}#{":#{opts[:port]}" if opts[:port]}/#{opts[:database]}" : opts[:database] 33: else 34: dbname = opts[:host] 35: end 36: conn = OCI8.new(opts[:user], opts[:password], dbname, opts[:privilege]) 37: conn.prefetch_rows = typecast_value_integer(opts[:prefetch_rows]) if opts[:prefetch_rows] 38: conn.autocommit = true 39: conn.non_blocking = true 40: 41: # The ruby-oci8 gem which retrieves oracle columns with a type of 42: # DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE is complex based on the 43: # ruby version (1.9.2 or later) and Oracle version (9 or later) 44: # In the now standard case of 1.9.2 and Oracle 9 or later, the timezone 45: # is determined by the Oracle session timezone. Thus if the user 46: # requests Sequel provide UTC timezone to the application, 47: # we need to alter the session timezone to be UTC 48: if Sequel.application_timezone == :utc 49: conn.exec("ALTER SESSION SET TIME_ZONE='-00:00'") 50: end 51: 52: class << conn 53: attr_reader :prepared_statements 54: end 55: conn.instance_variable_set(:@prepared_statements, {}) 56: 57: conn 58: end
# File lib/sequel/adapters/oracle.rb, line 60 60: def execute(sql, opts={}, &block) 61: _execute(nil, sql, opts, &block) 62: end