Class Sequel::Oracle::Database
In: lib/sequel/adapters/oracle.rb
Parent: Sequel::Database

Methods

Included Modules

DatabaseMethods

Constants

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

Public Instance methods

[Source]

    # File lib/sequel/adapters/oracle.rb, line 16
16:       def connect(server)
17:         opts = server_opts(server)
18:         if opts[:database]
19:           dbname = opts[:host] ? \
20:             "//#{opts[:host]}#{":#{opts[:port]}" if opts[:port]}/#{opts[:database]}" : opts[:database]
21:         else
22:           dbname = opts[:host]
23:         end
24:         conn = OCI8.new(opts[:user], opts[:password], dbname, opts[:privilege])
25:         conn.autocommit = true
26:         conn.non_blocking = true
27:         
28:         # The ruby-oci8 gem which retrieves oracle columns with a type of
29:         # DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE is complex based on the
30:         # ruby version (1.9.2 or later) and Oracle version (9 or later)
31:         # In the now standard case of 1.9.2 and Oracle 9 or later, the timezone
32:         # is determined by the Oracle session timezone. Thus if the user
33:         # requests Sequel provide UTC timezone to the application,
34:         # we need to alter the session timezone to be UTC
35:         if Sequel.application_timezone == :utc
36:           conn.exec("ALTER SESSION SET TIME_ZONE='-00:00'")
37:         end
38:         
39:         conn
40:       end

[Source]

    # File lib/sequel/adapters/oracle.rb, line 42
42:       def dataset(opts = nil)
43:         Oracle::Dataset.new(self, opts)
44:       end
do(sql, opts={})

Alias for execute

[Source]

    # File lib/sequel/adapters/oracle.rb, line 74
74:       def execute(sql, opts={})
75:         synchronize(opts[:server]) do |conn|
76:           begin
77:             r = log_yield(sql){conn.exec(sql)}
78:             yield(r) if block_given?
79:             r
80:           rescue OCIException => e
81:             raise_error(e, :disconnect=>CONNECTION_ERROR_CODES.include?(e.code))
82:           end
83:         end
84:       end

[Source]

    # File lib/sequel/adapters/oracle.rb, line 46
46:       def schema_parse_table(table, opts={})
47:         ds = dataset
48:         ds.identifier_output_method = :downcase
49:         schema_and_table = "#{"#{quote_identifier(opts[:schema])}." if opts[:schema]}#{quote_identifier(table)}"
50:         table_schema = []
51:         metadata = transaction(opts){|conn| conn.describe_table(schema_and_table)}
52:         metadata.columns.each do |column|
53:           table_schema << [
54:             column.name.downcase.to_sym,
55:             {
56:               :type => column.data_type,
57:               :db_type => column.type_string.split(' ')[0],
58:               :type_string => column.type_string,
59:               :charset_form => column.charset_form,
60:               :char_used => column.char_used?,
61:               :char_size => column.char_size,
62:               :data_size => column.data_size,
63:               :precision => column.precision,
64:               :scale => column.scale,
65:               :fsprecision => column.fsprecision,
66:               :lfprecision => column.lfprecision,
67:               :allow_null => column.nullable?
68:             }
69:           ]
70:         end
71:         table_schema
72:       end

[Validate]