Class: DbMeta::Oracle::Column
- Inherits:
-
Object
- Object
- DbMeta::Oracle::Column
- Defined in:
- lib/db_meta/oracle/types/column.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#data_default ⇒ Object
Returns the value of attribute data_default.
-
#data_length ⇒ Object
Returns the value of attribute data_length.
-
#data_precision ⇒ Object
Returns the value of attribute data_precision.
-
#data_scale ⇒ Object
Returns the value of attribute data_scale.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nullable ⇒ Object
Returns the value of attribute nullable.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
4 5 6 |
# File 'lib/db_meta/oracle/types/column.rb', line 4 def comment @comment end |
#data_default ⇒ Object
Returns the value of attribute data_default.
4 5 6 |
# File 'lib/db_meta/oracle/types/column.rb', line 4 def data_default @data_default end |
#data_length ⇒ Object
Returns the value of attribute data_length.
4 5 6 |
# File 'lib/db_meta/oracle/types/column.rb', line 4 def data_length @data_length end |
#data_precision ⇒ Object
Returns the value of attribute data_precision.
4 5 6 |
# File 'lib/db_meta/oracle/types/column.rb', line 4 def data_precision @data_precision end |
#data_scale ⇒ Object
Returns the value of attribute data_scale.
4 5 6 |
# File 'lib/db_meta/oracle/types/column.rb', line 4 def data_scale @data_scale end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/db_meta/oracle/types/column.rb', line 4 def name @name end |
#nullable ⇒ Object
Returns the value of attribute nullable.
4 5 6 |
# File 'lib/db_meta/oracle/types/column.rb', line 4 def nullable @nullable end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/db_meta/oracle/types/column.rb', line 4 def type @type end |
Class Method Details
.all(args = {}) ⇒ Object
13 14 15 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 |
# File 'lib/db_meta/oracle/types/column.rb', line 13 def self.all(args = {}) columns = [] connection = Connection.instance.get cursor = connection.exec("select column_name, data_type, data_length, data_precision, data_scale, nullable, data_default from user_tab_columns where table_name = '#{args[:object_name]}' order by column_id") while (row = cursor.fetch) column = Column.new column.name = row[0].to_s column.type = row[1].to_s column.data_length = row[2].to_i column.data_precision = row[3].to_i column.data_scale = row[4].to_i column.nullable = row[5].to_s column.data_default = row[6].to_s # column comments cursor2 = connection.exec("select comments from user_col_comments where table_name = '#{args[:object_name]}' and column_name = '#{column.name}'") while (row2 = cursor2.fetch) column.comment = row2[0].to_s end cursor2.close columns << column end cursor.close columns rescue connection.loggoff end |
Instance Method Details
#extract ⇒ Object
6 7 8 9 10 11 |
# File 'lib/db_meta/oracle/types/column.rb', line 6 def extract buffer = ("%-30s" % @name).to_s buffer << " #{convert_type}" buffer << " DEFAULT #{@data_default.strip}" if @data_default.size > 0 buffer end |