Class: DbMeta::Oracle::Sequence
- Defined in:
- lib/db_meta/oracle/types/sequence.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#cache_size ⇒ Object
readonly
Returns the value of attribute cache_size.
-
#cycle_flag ⇒ Object
readonly
Returns the value of attribute cycle_flag.
-
#increment_by ⇒ Object
readonly
Returns the value of attribute increment_by.
-
#last_number ⇒ Object
readonly
Returns the value of attribute last_number.
-
#max_value ⇒ Object
readonly
Returns the value of attribute max_value.
-
#min_value ⇒ Object
readonly
Returns the value of attribute min_value.
-
#order_flag ⇒ Object
readonly
Returns the value of attribute order_flag.
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
#cache_size ⇒ Object (readonly)
Returns the value of attribute cache_size.
6 7 8 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 6 def cache_size @cache_size end |
#cycle_flag ⇒ Object (readonly)
Returns the value of attribute cycle_flag.
6 7 8 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 6 def cycle_flag @cycle_flag end |
#increment_by ⇒ Object (readonly)
Returns the value of attribute increment_by.
6 7 8 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 6 def increment_by @increment_by end |
#last_number ⇒ Object (readonly)
Returns the value of attribute last_number.
6 7 8 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 6 def last_number @last_number end |
#max_value ⇒ Object (readonly)
Returns the value of attribute max_value.
6 7 8 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 6 def max_value @max_value end |
#min_value ⇒ Object (readonly)
Returns the value of attribute min_value.
6 7 8 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 6 def min_value @min_value end |
#order_flag ⇒ Object (readonly)
Returns the value of attribute order_flag.
6 7 8 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 6 def order_flag @order_flag end |
Instance Method Details
#extract(args = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 26 def extract(args = {}) buffer = [block(@name)] buffer << "CREATE SEQUENCE #{@name}" buffer << " START WITH #{@last_number}" buffer << " MAXVALUE #{@max_value}" buffer << " MINVALUE #{@min_value}" buffer << ((@cycle_flag == "N") ? " NOCYCLE" : " CYCLE") buffer << ((@cache_size == 0) ? " NOCACHE" : " CACHE #{@cache_size}") buffer << ((@order_flag == "N") ? " NOORDER" : " ORDER") buffer << ";" buffer << nil buffer.join("\n") end |
#fetch(args = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/db_meta/oracle/types/sequence.rb', line 8 def fetch(args = {}) connection_class = args[:connection_class] || Connection connection = connection_class.instance.get cursor = connection.exec("select to_char(min_value), to_char(max_value), to_char(increment_by), cycle_flag, order_flag, to_char(cache_size), to_char(last_number) from user_sequences where sequence_name = '#{@name}'") while (row = cursor.fetch) @min_value = row[0].to_i @max_value = row[1].to_i @increment_by = row[2].to_i @cycle_flag = row[3].to_s @order_flag = row[4].to_s @cache_size = row[5].to_i @last_number = row[6].to_i end cursor.close ensure connection.logoff end |