Class: DbMeta::Oracle::Procedure

Inherits:
Base
  • Object
show all
Defined in:
lib/db_meta/oracle/types/procedure.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

#sourceObject (readonly)

Returns the value of attribute source.



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

def source
  @source
end

Instance Method Details

#extract(args = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/db_meta/oracle/types/procedure.rb', line 21

def extract(args = {})
  buffer = [block(@name)]
  buffer << "create or replace #{@source.strip}"
  buffer << "/"
  buffer << nil
  buffer.join("\n")
end

#fetch(args = {}) ⇒ Object



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

def fetch(args = {})
  @source = ""
  connection_class = args[:connection_class] || Connection
  connection = connection_class.instance.get
  cursor = connection.exec("select text from user_source where type = 'PROCEDURE' and name = '#{@name}' order by line")
  while (row = cursor.fetch)
    @source << row[0].to_s
  end
  cursor.close
ensure
  connection.logoff
end