Class: OCI8::Metadata::Column

Inherits:
Base show all
Defined in:
lib/oci8/metadata.rb

Overview

Metadata for a sequence.

This is returned by:

  • OCI8::Metadata::Table#columns

Instance Method Summary collapse

Methods inherited from Base

#obj_id, #obj_name, #obj_schema, #timestamp

Instance Method Details

#char_sizeObject

returns the column character length which is the number of characters allowed in the column. It is the counterpart of OCI8::Metadata::Column#data_size which gets the byte length.



1348
1349
1350
# File 'lib/oci8/metadata.rb', line 1348

def char_size
  __ub2(OCI_ATTR_CHAR_SIZE)
end

#char_used?Boolean

returns the type of length semantics of the column.

:byte

byte-length semantics

:char

character-length semantics.

(unavailable on Oracle 8.1 or lower)

Returns:

  • (Boolean)


1341
1342
1343
# File 'lib/oci8/metadata.rb', line 1341

def char_used?
  __ub4(OCI_ATTR_CHAR_USED) != 0
end

#charset_formObject

The character set form, if the column is of a string/character type



1434
1435
1436
# File 'lib/oci8/metadata.rb', line 1434

def charset_form
  __charset_form
end

#charset_idObject

The character set id, if the column is of a string/character type



1429
1430
1431
# File 'lib/oci8/metadata.rb', line 1429

def charset_id
  __ub2(OCI_ATTR_CHARSET_ID)
end

#charset_nameObject

The character set name, if the column is of a string/character type



1458
1459
1460
# File 'lib/oci8/metadata.rb', line 1458

def charset_name
  __charset_name(charset_id)
end

#data_sizeObject

The maximum size of the column. This length is returned in bytes and not characters for strings and raws. This returns character length multiplied by NLS ratio for character-length semantics columns when using Oracle 9i or upper.



1366
1367
1368
# File 'lib/oci8/metadata.rb', line 1366

def data_size
  __ub2_nc(OCI_ATTR_DATA_SIZE)
end

#data_typeObject

the datatype of the column.



1371
1372
1373
# File 'lib/oci8/metadata.rb', line 1371

def data_type
  __data_type
end

#fsprecisionObject

The fractional seconds precision of a datetime or interval.

(unavailable on Oracle 8.1 or lower)



1445
1446
1447
# File 'lib/oci8/metadata.rb', line 1445

def fsprecision
  __ub1(OCI_ATTR_FSPRECISION)
end

#inspectObject

:nodoc:



1470
1471
1472
# File 'lib/oci8/metadata.rb', line 1470

def inspect # :nodoc:
  "#<#{self.class.name}: #{name} #{__type_string}>"
end

#lfprecisionObject

The leading field precision of an interval

(unavailable on Oracle 8.1 or lower)



1452
1453
1454
# File 'lib/oci8/metadata.rb', line 1452

def lfprecision
  __ub1(OCI_ATTR_LFPRECISION)
end

#nameObject

column name



1376
1377
1378
# File 'lib/oci8/metadata.rb', line 1376

def name
  __text(OCI_ATTR_NAME)
end

#nullable?Boolean

Returns 0 if null values are not permitted for the column

Returns:

  • (Boolean)


1397
1398
1399
# File 'lib/oci8/metadata.rb', line 1397

def nullable?
  __boolean(OCI_ATTR_IS_NULL)
end

#precisionObject

The precision of numeric columns. If the precision is nonzero and scale is -127, then it is a FLOAT, else it is a NUMBER(precision, scale). For the case when precision is 0, NUMBER(precision, scale) can be represented simply as NUMBER.



1384
1385
1386
# File 'lib/oci8/metadata.rb', line 1384

def precision
  __is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
end

#scaleObject

The scale of numeric columns. If the precision is nonzero and scale is -127, then it is a FLOAT, else it is a NUMBER(precision, scale). For the case when precision is 0, NUMBER(precision, scale) can be represented simply as NUMBER.



1392
1393
1394
# File 'lib/oci8/metadata.rb', line 1392

def scale
  __sb1(OCI_ATTR_SCALE)
end

#schema_nameObject

Returns a string with the schema name under which the type has been created



1413
1414
1415
1416
# File 'lib/oci8/metadata.rb', line 1413

def schema_name
  rv = __text(OCI_ATTR_SCHEMA_NAME)
  rv.length == 0 ? nil : rv
end

#to_sObject



1466
1467
1468
# File 'lib/oci8/metadata.rb', line 1466

def to_s
  %Q{"#{name}" #{__type_string}}
end

#type_metadataObject

to type metadata if possible



1419
1420
1421
1422
1423
1424
1425
1426
# File 'lib/oci8/metadata.rb', line 1419

def 
  case __ub2(OCI_ATTR_DATA_TYPE)
  when 108, 110 # named_type or ref
    (OCI8::Metadata::Type)
  else
    nil
  end
end

#type_nameObject

Returns a string which is the type name. The returned value will contain the type name if the datatype is :named_type or :ref. If the datatype is :named_type, the name of the named datatype’s type is returned. If the datatype is :ref, the type name of the named datatype pointed to by the REF is returned



1407
1408
1409
1410
# File 'lib/oci8/metadata.rb', line 1407

def type_name
  rv = __text(OCI_ATTR_TYPE_NAME)
  rv.length == 0 ? nil : rv
end

#type_stringObject



1462
1463
1464
# File 'lib/oci8/metadata.rb', line 1462

def type_string
  __type_string
end