Class | Sequel::Oracle::Database |
In: |
lib/sequel/adapters/oracle.rb
|
Parent: | Sequel::Database |
CONNECTION_ERROR_CODES | = | [ 28, 1012, 2396, 3113, 3114 ].freeze | ORA-00028: your session has been killed ORA-01012: not logged on ORA-02396: exceeded maximum idle time, please connect again 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)}, :clob=>:read.to_proc | ||
PS_TYPES | = | {'string'=>String, 'integer'=>Integer, 'float'=>Float, 'decimal'=>Float, 'date'=>Time, 'datetime'=>Time, 'time'=>Time, 'boolean'=>String, 'blob'=>OCI8::BLOB}.freeze |
conversion_procs | [R] | Hash of conversion procs for this database. |
# File lib/sequel/adapters/oracle.rb, line 27 27: def connect(server) 28: opts = server_opts(server) 29: if opts[:database] 30: dbname = opts[:host] ? \ 31: "//#{opts[:host]}#{":#{opts[:port]}" if opts[:port]}/#{opts[:database]}" : opts[:database] 32: else 33: dbname = opts[:host] 34: end 35: conn = OCI8.new(opts[:user], opts[:password], dbname, opts[:privilege]) 36: if prefetch_rows = opts.fetch(:prefetch_rows, 100) 37: conn.prefetch_rows = typecast_value_integer(prefetch_rows) 38: end 39: conn.autocommit = true 40: conn.non_blocking = true 41: 42: # The ruby-oci8 gem which retrieves oracle columns with a type of 43: # DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE is complex based on the 44: # ruby version and Oracle version (9 or later) 45: # In the now standard case of Oracle 9 or later, the timezone 46: # is determined by the Oracle session timezone. Thus if the user 47: # requests Sequel provide UTC timezone to the application, 48: # we need to alter the session timezone to be UTC 49: if Sequel.application_timezone == :utc 50: conn.exec("ALTER SESSION SET TIME_ZONE='-00:00'") 51: end 52: 53: class << conn 54: attr_reader :prepared_statements 55: end 56: conn.instance_variable_set(:@prepared_statements, {}) 57: 58: conn 59: end
# File lib/sequel/adapters/oracle.rb, line 61 61: def disconnect_connection(c) 62: c.logoff 63: rescue OCIException 64: nil 65: end
# File lib/sequel/adapters/oracle.rb, line 67 67: def execute(sql, opts=OPTS, &block) 68: _execute(nil, sql, opts, &block) 69: end