forked from activewarehouse/rails_sql_views
-
Notifications
You must be signed in to change notification settings - Fork 1
/
oci_adapter.rb
32 lines (27 loc) · 824 Bytes
/
oci_adapter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module ActiveRecord
module ConnectionAdapters
class OciAdapter
# Returns true as this adapter supports views.
def supports_views?
true
end
def nonview_tables(name = nil) #:nodoc:
tables = []
execute("SELECT TABLE_NAME FROM USER_TABLES", name).each { |row| tables << row[0] }
tables
end
def views(name = nil) #:nodoc:
views = []
execute("SELECT VIEW_NAME FROM USER_VIEWS", name).each { |row| views << row[0] }
views
end
# Get the view select statement for the specified table.
def view_select_statement(view, name=nil)
row = execute("SELECT TEXT FROM USER_VIEWS WHERE VIEW_NAME = '#{view}'", name).each do |row|
return row[0]
end
raise "No view called #{view} found"
end
end
end
end