Class: DbMeta::Oracle::TableDataCollection
- Inherits:
-
Object
- Object
- DbMeta::Oracle::TableDataCollection
- Includes:
- Helper
- Defined in:
- lib/db_meta/oracle/types/table_data_collection.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#extract_type ⇒ Object
readonly
Returns the value of attribute extract_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #ddl_drop ⇒ Object
- #extract(args = {}) ⇒ Object
-
#initialize(args = {}) ⇒ TableDataCollection
constructor
A new instance of TableDataCollection.
- #system_object? ⇒ Boolean
Methods included from Helper
#block, #create_folder, #pluralize, #remove_folder, #type_sequence, #write_buffer_to_file
Constructor Details
#initialize(args = {}) ⇒ TableDataCollection
Returns a new instance of TableDataCollection.
8 9 10 11 12 13 14 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 8 def initialize(args={}) @name = args[:name] @type = args[:type] @status = :valid @extract_type = :default @tables = args[:tables] end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
6 7 8 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 6 def collection @collection end |
#extract_type ⇒ Object (readonly)
Returns the value of attribute extract_type.
6 7 8 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 6 def extract_type @extract_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 6 def name @name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 6 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 6 def type @type end |
Instance Method Details
#ddl_drop ⇒ Object
46 47 48 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 46 def ddl_drop '-- will automatically be dropped with table object' end |
#extract(args = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 16 def extract(args={}) buffer = [block(@name)] buffer << nil connection = Connection.instance.get @tables.each do |table| buffer << block(table.name, 40) name_type_map = {} table.columns.each do |column| name_type_map[column.name] = column.type end cursor = connection.exec("select * from #{table.name} #{table.get_core_data_where_clause}") cursor.fetch_hash do |item| buffer << "insert into #{table.name}(#{item.keys.join(', ')}) values(#{format_values(name_type_map, item)});" end cursor.close buffer << nil end buffer << 'commit;' buffer << nil buffer.join("\n") ensure connection.logoff end |
#system_object? ⇒ Boolean
50 51 52 |
# File 'lib/db_meta/oracle/types/table_data_collection.rb', line 50 def system_object? false end |