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
-
#autosequence ⇒ Object
Returns the value of attribute autosequence.
Instance Method Summary collapse
- #create_sequence(name, opts = OPTS) ⇒ Object
- #create_trigger(*args) ⇒ Object
- #current_user ⇒ Object
-
#database_type ⇒ Object
Oracle uses the :oracle database type.
- #drop_sequence(name) ⇒ Object
- #foreign_key_list(table, opts = OPTS) ⇒ Object
-
#global_index_namespace? ⇒ Boolean
Oracle namespaces indexes per table.
-
#server_version(server = nil) ⇒ Object
The version of the Oracle server, used for determining capability.
-
#supports_deferrable_constraints? ⇒ Boolean
Oracle supports deferrable constraints.
-
#supports_transaction_isolation_levels? ⇒ Boolean
Oracle supports transaction isolation levels.
- #tables(opts = OPTS) ⇒ Object
- #view_exists?(name) ⇒ Boolean
- #views(opts = OPTS) ⇒ Object
Methods included from Database::ResetIdentifierMangling
Instance Attribute Details
#autosequence ⇒ Object
Returns the value of attribute autosequence.
13 14 15 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 13 def autosequence @autosequence end |
Instance Method Details
#create_sequence(name, opts = OPTS) ⇒ Object
15 16 17 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 15 def create_sequence(name, opts=OPTS) self << create_sequence_sql(name, opts) end |
#create_trigger(*args) ⇒ Object
19 20 21 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 19 def create_trigger(*args) self << create_trigger_sql(*args) end |
#current_user ⇒ Object
23 24 25 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 23 def current_user @current_user ||= .get{sys_context('USERENV', 'CURRENT_USER')} end |
#database_type ⇒ Object
Oracle uses the :oracle database type
32 33 34 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 32 def database_type :oracle end |
#drop_sequence(name) ⇒ Object
27 28 29 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 27 def drop_sequence(name) self << drop_sequence_sql(name) end |
#foreign_key_list(table, opts = OPTS) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 36 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.
60 61 62 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 60 def global_index_namespace? false end |
#server_version(server = nil) ⇒ Object
The version of the Oracle server, used for determining capability.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 94 def server_version(server=nil) return @server_version if @server_version @server_version = synchronize(server) do |conn| (conn.server_version rescue nil) if conn.respond_to?(:server_version) end unless @server_version @server_version = if m = /(\d+)\.(\d+)\.?(\d+)?\.?(\d+)?/.match(fetch("select version from PRODUCT_COMPONENT_VERSION where lower(product) like 'oracle%'").single_value) (m[1].to_i*1000000) + (m[2].to_i*10000) + (m[3].to_i*100) + m[4].to_i else 0 end end @server_version end |
#supports_deferrable_constraints? ⇒ Boolean
Oracle supports deferrable constraints.
111 112 113 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 111 def supports_deferrable_constraints? true end |
#supports_transaction_isolation_levels? ⇒ Boolean
Oracle supports transaction isolation levels.
116 117 118 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 116 def supports_transaction_isolation_levels? true end |
#tables(opts = OPTS) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 66 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
85 86 87 88 89 90 91 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 85 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
76 77 78 79 80 81 82 83 |
# File 'lib/sequel/adapters/shared/oracle.rb', line 76 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 |