Class: OCI8::TDO
- Inherits:
-
Object
- Object
- OCI8::TDO
- Extended by:
- BindType::Util
- Defined in:
- lib/oci8/object.rb,
ext/oci8/object.c
Overview
OCI8::TDO is the class for Type Descriptor Object, which describe Oracle’s object type.
An instance of OCI8::TDO is specific to the connection. This means One TDO instance for a connection is not available to another connection.
Defined Under Namespace
Classes: Attr
Constant Summary collapse
- @@result_type_to_bindtype =
{ 'FLOAT' => Float, 'INTEGER' => Integer, 'NUMBER' => OraNumber, 'BINARY_FLOAT' => :binary_float, 'BINARY_DOUBLE' => :binary_double, 'TIMESTAMP' => :timestamp, 'TIMESTAMP WITH TZ' => :timestamp_tz, 'TIMESTAMP WITH LOCAL TZ' => :timestamp_ltz, 'INTERVAL YEAR TO MONTH' => :interval_ym, 'INTERVAL DAY TO SECOND' => :interval_ds, }
Instance Attribute Summary collapse
-
#alignment ⇒ Object
readonly
Returns the value of attribute alignment.
-
#attr_getters ⇒ Object
readonly
Returns the value of attribute attr_getters.
-
#attr_setters ⇒ Object
readonly
Returns the value of attribute attr_setters.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#class_methods ⇒ Object
readonly
mapping between class method’s ids and their return types.
-
#coll_attr ⇒ Object
readonly
Returns the value of attribute coll_attr.
-
#ind_size ⇒ Object
readonly
Returns the value of attribute ind_size.
-
#instance_methods ⇒ Object
readonly
mapping between instance method’s ids and their return types.
-
#ruby_class ⇒ Object
readonly
a subclass of OCI8::Object::Base.
-
#typename ⇒ Object
readonly
full-qualified object type name.
-
#val_size ⇒ Object
readonly
Returns the value of attribute val_size.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(con, metadata, klass) ⇒ TDO
constructor
A new instance of TDO.
- #inspect ⇒ Object
- #is_collection? ⇒ Boolean
Methods included from BindType::Util
default_timezone, default_timezone=
Constructor Details
#initialize(con, metadata, klass) ⇒ TDO
Returns a new instance of TDO.
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
# File 'lib/oci8/object.rb', line 349 def initialize(con, , klass) @ruby_class = klass @typename = .schema_name + '.' + .name setup(con, ) con.instance_variable_get(:@id_to_tdo)[.tdo_id] = self con.instance_variable_get(:@name_to_tdo)[@typename] = self con.instance_variable_get(:@name_to_tdo)[klass.typename] = self if .schema_name == con.username con.instance_variable_get(:@name_to_tdo)[.name] = self end case .typecode when :named_type initialize_named_type(con, ) when :named_collection initialize_named_collection(con, ) end end |
Instance Attribute Details
#alignment ⇒ Object (readonly)
Returns the value of attribute alignment.
320 321 322 |
# File 'lib/oci8/object.rb', line 320 def alignment @alignment end |
#attr_getters ⇒ Object (readonly)
Returns the value of attribute attr_getters.
324 325 326 |
# File 'lib/oci8/object.rb', line 324 def attr_getters @attr_getters end |
#attr_setters ⇒ Object (readonly)
Returns the value of attribute attr_setters.
325 326 327 |
# File 'lib/oci8/object.rb', line 325 def attr_setters @attr_setters end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
322 323 324 |
# File 'lib/oci8/object.rb', line 322 def attributes @attributes end |
#class_methods ⇒ Object (readonly)
mapping between class method’s ids and their return types. :none means a procedure.
CREATE OR REPLACE TYPE foo AS OBJECT (
STATIC FUNCTION bar RETURN INTEGER,
STATIC PROCEDURE baz,
);
=> {:bar => Integer, :baz => :none}
335 336 337 |
# File 'lib/oci8/object.rb', line 335 def class_methods @class_methods end |
#coll_attr ⇒ Object (readonly)
Returns the value of attribute coll_attr.
323 324 325 |
# File 'lib/oci8/object.rb', line 323 def coll_attr @coll_attr end |
#ind_size ⇒ Object (readonly)
Returns the value of attribute ind_size.
319 320 321 |
# File 'lib/oci8/object.rb', line 319 def ind_size @ind_size end |
#instance_methods ⇒ Object (readonly)
mapping between instance method’s ids and their return types. :none means a procedure.
CREATE OR REPLACE TYPE foo AS OBJECT (
MEMBER FUNCTION bar RETURN INTEGER,
MEMBER PROCEDURE baz,
);
=> {:bar => Integer, :baz => :none}
343 344 345 |
# File 'lib/oci8/object.rb', line 343 def instance_methods @instance_methods end |
#ruby_class ⇒ Object (readonly)
a subclass of OCI8::Object::Base
316 317 318 |
# File 'lib/oci8/object.rb', line 316 def ruby_class @ruby_class end |
#typename ⇒ Object (readonly)
full-qualified object type name.
e.g.
MDSYS.SDO_GEOMETRY
313 314 315 |
# File 'lib/oci8/object.rb', line 313 def typename @typename end |
#val_size ⇒ Object (readonly)
Returns the value of attribute val_size.
318 319 320 |
# File 'lib/oci8/object.rb', line 318 def val_size @val_size end |
Class Method Details
.check_metadata(con, metadata) ⇒ Object
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/oci8/object.rb', line 454 def self.(con, ) case .typecode when :char, :varchar, :varchar2 [ATTR_STRING, nil, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] when :raw [ATTR_RAW, nil, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] when :number, :decimal [ATTR_OCINUMBER, nil, SIZE_OF_OCINUMBER, 2, ALIGNMENT_OF_OCINUMBER] when :integer, :smallint [ATTR_INTEGER, nil, SIZE_OF_OCINUMBER, 2, ALIGNMENT_OF_OCINUMBER] when :real, :double, :float [ATTR_FLOAT, nil, SIZE_OF_OCINUMBER, 2, ALIGNMENT_OF_OCINUMBER] when :date [ATTR_OCIDATE, nil, SIZE_OF_OCIDATE, 2, ALIGNMENT_OF_OCIDATE, Proc.new do |val| datetime_to_array(val, :date) end, # set_proc Proc.new do |val| array_to_datetime(val, :local) end, # get_proc ] when :binary_double [ATTR_BINARY_DOUBLE, nil, SIZE_OF_DOUBLE, 2, ALIGNMENT_OF_DOUBLE] when :binary_float [ATTR_BINARY_FLOAT, nil, SIZE_OF_FLOAT, 2, ALIGNMENT_OF_FLOAT] when :named_type tdo = con.(.) [ATTR_NAMED_TYPE, tdo, tdo.val_size, tdo.ind_size, tdo.alignment] when :named_collection #datatype, typeinfo, = OCI8::TDO.check_metadata(con, metadata.type_metadata.collection_element) #[ATTR_NAMED_COLLECTION, [datatype, typeinfo], SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] tdo = con.(.) [ATTR_NAMED_COLLECTION, tdo, tdo.val_size, tdo.ind_size, tdo.alignment] when :clob if .charset_form != :nchar [ATTR_CLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] else [ATTR_NCLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] end when :blob [ATTR_BLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] when :bfile [ATTR_BFILE, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] else raise "unsupported typecode #{.typecode}" end end |
Instance Method Details
#inspect ⇒ Object
434 435 436 |
# File 'lib/oci8/object.rb', line 434 def inspect "#<#{self.class}:#@typename>" end |
#is_collection? ⇒ Boolean
345 346 347 |
# File 'lib/oci8/object.rb', line 345 def is_collection? @coll_attr ? true : false end |