class DbMeta::Oracle::Synonym

Attributes

table_name[R]
table_owner[R]

Public Class Methods

new(args = {}) click to toggle source
Calls superclass method DbMeta::Oracle::Base::new
# File lib/db_meta/oracle/types/synonym.rb, line 8
def initialize(args = {})
  super(args)

  @extract_type = :merged
end

Public Instance Methods

extract(args = {}) click to toggle source
# File lib/db_meta/oracle/types/synonym.rb, line 27
def extract(args = {})
  line = ""
  line << "CREATE OR REPLACE SYNONYM #{@name} FOR "
  line << "#{@table_owner}." if @table_owner.size > 0
  line << @table_name.to_s
  line << "@#{@db_link}" if @db_link.size > 0
  line << ";"

  buffer = []
  buffer << line
  buffer.join("\n")
end
fetch(args = {}) click to toggle source
# File lib/db_meta/oracle/types/synonym.rb, line 14
def fetch(args = {})
  connection = Connection.instance.get
  cursor = connection.exec("select table_owner, table_name, db_link from user_synonyms where synonym_name = '#{@name}'")
  while (row = cursor.fetch)
    @table_owner = row[0].to_s
    @table_name = row[1].to_s
    @db_link = row[2].to_s
  end
  cursor.close
ensure
  connection.logoff
end