Module: Sequel::Oracle::DatabaseMethods

Extended by:
Database::ResetIdentifierMangling
Included in:
JDBC::Oracle::DatabaseMethods, Database
Defined in:
lib/sequel/adapters/shared/oracle.rb

Constant Summary collapse

TEMPORARY =
'GLOBAL TEMPORARY '.freeze
AUTOINCREMENT =
''.freeze
IGNORE_OWNERS =
%w'APEX_040000 CTXSYS EXFSYS MDSYS OLAPSYS ORDDATA ORDSYS SYS SYSTEM XDB XDBMETADATA XDBPM XFILES WMSYS'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Database::ResetIdentifierMangling

extended

Instance Attribute Details

#autosequenceObject

Returns the value of attribute autosequence.



11
12
13
# File 'lib/sequel/adapters/shared/oracle.rb', line 11

def autosequence
  @autosequence
end

Instance Method Details

#create_sequence(name, opts = OPTS) ⇒ Object



13
14
15
# File 'lib/sequel/adapters/shared/oracle.rb', line 13

def create_sequence(name, opts=OPTS)
  self << create_sequence_sql(name, opts)
end

#create_trigger(*args) ⇒ Object



17
18
19
# File 'lib/sequel/adapters/shared/oracle.rb', line 17

def create_trigger(*args)
  self << create_trigger_sql(*args)
end

#current_userObject



21
22
23
# File 'lib/sequel/adapters/shared/oracle.rb', line 21

def current_user
  @current_user ||= .get{sys_context('USERENV', 'CURRENT_USER')}
end

#database_typeObject

Oracle uses the :oracle database type



30
31
32
# File 'lib/sequel/adapters/shared/oracle.rb', line 30

def database_type
  :oracle
end

#drop_sequence(name) ⇒ Object



25
26
27
# File 'lib/sequel/adapters/shared/oracle.rb', line 25

def drop_sequence(name)
  self << drop_sequence_sql(name)
end

#foreign_key_list(table, opts = OPTS) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sequel/adapters/shared/oracle.rb', line 34

def foreign_key_list(table, opts=OPTS)
  m = output_identifier_meth
  im = input_identifier_meth
  schema, table = schema_and_table(table)
  ds = .
    from(:all_cons_columns___pc, :all_constraints___p, :all_cons_columns___fc, :all_constraints___f).
    where(:f__table_name=>im.call(table), :f__constraint_type=>'R', :p__owner=>:f__r_owner, :p__constraint_name=>:f__r_constraint_name, :pc__owner=>:p__owner, :pc__constraint_name=>:p__constraint_name, :pc__table_name=>:p__table_name, :fc__owner=>:f__owner, :fc__constraint_name=>:f__constraint_name, :fc__table_name=>:f__table_name, :fc__position=>:pc__position).
    select(:p__table_name___table, :pc__column_name___key, :fc__column_name___column, :f__constraint_name___name).
    order(:table, :fc__position)
  ds = ds.where(:f__schema_name=>im.call(schema)) if schema

  fks = {}
  ds.each do |r|
    if fk = fks[r[:name]]
      fk[:columns] << m.call(r[:column])
      fk[:key] << m.call(r[:key])
    else
      fks[r[:name]] = {:name=>m.call(r[:name]), :columns=>[m.call(r[:column])], :table=>m.call(r[:table]), :key=>[m.call(r[:key])]}
    end
  end
  fks.values
end

#global_index_namespace?Boolean

Oracle namespaces indexes per table.

Returns:

  • (Boolean)


58
59
60
# File 'lib/sequel/adapters/shared/oracle.rb', line 58

def global_index_namespace?
  false
end

#supports_deferrable_constraints?Boolean

Oracle supports deferrable constraints.

Returns:

  • (Boolean)


92
93
94
# File 'lib/sequel/adapters/shared/oracle.rb', line 92

def supports_deferrable_constraints?
  true
end

#supports_transaction_isolation_levels?Boolean

Oracle supports transaction isolation levels.

Returns:

  • (Boolean)


97
98
99
# File 'lib/sequel/adapters/shared/oracle.rb', line 97

def supports_transaction_isolation_levels?
  true
end

#tables(opts = OPTS) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/sequel/adapters/shared/oracle.rb', line 64

def tables(opts=OPTS)
  m = output_identifier_meth
  .from(:all_tables).
    server(opts[:server]).
    where(:dropped=>'NO').
    exclude(:owner=>IGNORE_OWNERS).
    select(:table_name).
    map{|r| m.call(r[:table_name])}
end

#view_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
86
87
88
89
# File 'lib/sequel/adapters/shared/oracle.rb', line 83

def view_exists?(name) 
  m = input_identifier_meth
  .from(:all_views).
    exclude(:owner=>IGNORE_OWNERS).
    where(:view_name=>m.call(name)).
    count > 0
end

#views(opts = OPTS) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/sequel/adapters/shared/oracle.rb', line 74

def views(opts=OPTS) 
  m = output_identifier_meth
  .from(:all_views).
    server(opts[:server]).
    exclude(:owner=>IGNORE_OWNERS).
    select(:view_name).
    map{|r| m.call(r[:view_name])}
end