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.
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/oci8/object.rb', line 372 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.
343 344 345 |
# File 'lib/oci8/object.rb', line 343 def alignment @alignment end |
#attr_getters ⇒ Object (readonly)
Returns the value of attribute attr_getters.
347 348 349 |
# File 'lib/oci8/object.rb', line 347 def attr_getters @attr_getters end |
#attr_setters ⇒ Object (readonly)
Returns the value of attribute attr_setters.
348 349 350 |
# File 'lib/oci8/object.rb', line 348 def attr_setters @attr_setters end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
345 346 347 |
# File 'lib/oci8/object.rb', line 345 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}
358 359 360 |
# File 'lib/oci8/object.rb', line 358 def class_methods @class_methods end |
#coll_attr ⇒ Object (readonly)
Returns the value of attribute coll_attr.
346 347 348 |
# File 'lib/oci8/object.rb', line 346 def coll_attr @coll_attr end |
#ind_size ⇒ Object (readonly)
Returns the value of attribute ind_size.
342 343 344 |
# File 'lib/oci8/object.rb', line 342 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}
366 367 368 |
# File 'lib/oci8/object.rb', line 366 def instance_methods @instance_methods end |
#ruby_class ⇒ Object (readonly)
a subclass of OCI8::Object::Base
339 340 341 |
# File 'lib/oci8/object.rb', line 339 def ruby_class @ruby_class end |
#typename ⇒ Object (readonly)
full-qualified object type name.
e.g.
MDSYS.SDO_GEOMETRY
336 337 338 |
# File 'lib/oci8/object.rb', line 336 def typename @typename end |
#val_size ⇒ Object (readonly)
Returns the value of attribute val_size.
341 342 343 |
# File 'lib/oci8/object.rb', line 341 def val_size @val_size end |
Class Method Details
.check_metadata(con, metadata) ⇒ Object
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/oci8/object.rb', line 476 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_time(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
456 457 458 |
# File 'lib/oci8/object.rb', line 456 def inspect "#<#{self.class}:#@typename>" end |
#is_collection? ⇒ Boolean
368 369 370 |
# File 'lib/oci8/object.rb', line 368 def is_collection? @coll_attr ? true : false end |