class DbMeta::Oracle::View
Public Class Methods
new(args = {})
click to toggle source
Calls superclass method
DbMeta::Oracle::Base::new
# File lib/db_meta/oracle/types/view.rb, line 6 def initialize(args = {}) super(args) @comment = nil # view level comment end
Public Instance Methods
extract(args = {})
click to toggle source
# File lib/db_meta/oracle/types/view.rb, line 27 def extract(args = {}) buffer = [block(@name)] buffer << "CREATE OR REPLACE VIEW #{@name}" buffer << "(" # add columns @columns.each_with_index do |c, index| buffer << " #{c.name}#{"," if index + 1 < @columns.size}" end buffer << ")" buffer << "AS" buffer << @source.strip buffer[-1] += ";" buffer << nil # view comments if @comment buffer << "COMMENT ON VIEW #{@name} IS '#{@comment.text("'", "''")}';" end # view column comments @columns.each do |column| next if column.comment.size == 0 buffer << "COMMENT ON COLUMN #{@name}.#{column.name} IS '#{column.comment.gsub("'", "''")}';" end buffer.join("\n") end
fetch(args = {})
click to toggle source
# File lib/db_meta/oracle/types/view.rb, line 12 def fetch(args = {}) @comment = Comment.find(type: "TABLE", name: @name) @columns = Column.all(object_name: @name) @source = "" connection = Connection.instance.get cursor = Connection.instance.get.exec("select text from user_views where view_name = '#{@name}'") while (row = cursor.fetch) @source << row[0].to_s end cursor.close ensure connection.logoff end