Class: DbMeta::Oracle::Trigger
- Defined in:
- lib/db_meta/oracle/types/trigger.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#for_each ⇒ Object
Returns the value of attribute for_each.
-
#referencing_names ⇒ Object
Returns the value of attribute referencing_names.
-
#table_name ⇒ Object
Returns the value of attribute table_name.
-
#tigger_body ⇒ Object
Returns the value of attribute tigger_body.
-
#trigger_event ⇒ Object
Returns the value of attribute trigger_event.
-
#trigger_type ⇒ Object
Returns the value of attribute trigger_type.
Attributes inherited from Base
#extract_type, #name, #status, #system_object, #type
Instance Method Summary collapse
- #extract(args = {}) ⇒ Object
- #fetch(args = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Trigger
constructor
A new instance of Trigger.
Methods inherited from Base
#ddl_drop, from_type, register_type, #system_object?
Methods included from Helper
#block, #create_folder, #pluralize, #remove_folder, #type_sequence, #write_buffer_to_file
Constructor Details
#initialize(args = {}) ⇒ Trigger
Returns a new instance of Trigger.
8 9 10 11 12 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 8 def initialize(args = {}) super @extract_type = :embedded end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 6 def description @description end |
#for_each ⇒ Object
Returns the value of attribute for_each.
6 7 8 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 6 def for_each @for_each end |
#referencing_names ⇒ Object
Returns the value of attribute referencing_names.
6 7 8 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 6 def referencing_names @referencing_names end |
#table_name ⇒ Object
Returns the value of attribute table_name.
6 7 8 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 6 def table_name @table_name end |
#tigger_body ⇒ Object
Returns the value of attribute tigger_body.
6 7 8 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 6 def tigger_body @tigger_body end |
#trigger_event ⇒ Object
Returns the value of attribute trigger_event.
6 7 8 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 6 def trigger_event @trigger_event end |
#trigger_type ⇒ Object
Returns the value of attribute trigger_type.
6 7 8 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 6 def trigger_type @trigger_type end |
Instance Method Details
#extract(args = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 34 def extract(args = {}) buffer = [] buffer << "CREATE OR REPLACE TRIGGER #{@name}" buffer << "#{@trigger_type} #{@triggering_event}" buffer << "ON #{@table_name}" buffer << @referencing_names.to_s buffer << @for_each.to_s if @for_each buffer << @trigger_body.strip.to_s if @trigger_body buffer << "/" buffer << nil buffer.join("\n") end |
#fetch(args = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/db_meta/oracle/types/trigger.rb', line 14 def fetch(args = {}) connection_class = args[:connection_class] || Connection connection = connection_class.instance.get cursor = connection.exec("select trigger_type, triggering_event, table_name, referencing_names, description, trigger_body from user_triggers where trigger_name = '#{@name}'") while (row = cursor.fetch) @trigger_type = row[0].to_s @triggering_event = row[1].to_s @table_name = row[2].to_s @referencing_names = row[3].to_s @description = row[4].to_s @trigger_body = row[5].to_s end parse_trigger_type cursor.close ensure connection.logoff end |