Class: DbMeta::Oracle::DatabaseLink

Inherits:
Base
  • Object
show all
Defined in:
lib/db_meta/oracle/types/database_link.rb

Constant Summary

Constants inherited from Base

Base::TYPES

Instance Attribute Summary collapse

Attributes inherited from Base

#extract_type, #name, #status, #system_object, #type

Instance Method Summary collapse

Methods inherited from Base

#ddl_drop, from_type, #initialize, register_type, #system_object?

Methods included from Helper

#block, #create_folder, #pluralize, #remove_folder, #type_sequence, #write_buffer_to_file

Constructor Details

This class inherits a constructor from DbMeta::Oracle::Base

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/db_meta/oracle/types/database_link.rb', line 6

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/db_meta/oracle/types/database_link.rb', line 6

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



6
7
8
# File 'lib/db_meta/oracle/types/database_link.rb', line 6

def username
  @username
end

Instance Method Details

#extract(args = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/db_meta/oracle/types/database_link.rb', line 22

def extract(args = {})
  buffer = []
  buffer << "CREATE DATABASE LINK #{@name}"
  buffer << " CONNECT TO #{@username}"
  buffer << " IDENTIFIED BY :1"
  buffer << " USING '#{@host}';"
  buffer << nil
  buffer.join("\n")
end

#fetch(args = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/db_meta/oracle/types/database_link.rb', line 8

def fetch(args = {})
  connection_class = args[:connection_class] || Connection
  connection = connection_class.instance.get
  cursor = connection.exec("select username, password, host from user_db_links where db_link = '#{@name}'")
  while (row = cursor.fetch)
    @username = row[0].to_s
    @password = row[1].to_s
    @host = row[2].to_s
  end
  cursor.close
ensure
  connection.logoff
end