Class: 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
named_type.
-
#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.
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/oci8/object.rb', line 326 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.
297 298 299 |
# File 'lib/oci8/object.rb', line 297 def alignment @alignment end |
#attr_getters ⇒ Object (readonly)
Returns the value of attribute attr_getters.
301 302 303 |
# File 'lib/oci8/object.rb', line 301 def attr_getters @attr_getters end |
#attr_setters ⇒ Object (readonly)
Returns the value of attribute attr_setters.
302 303 304 |
# File 'lib/oci8/object.rb', line 302 def attr_setters @attr_setters end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
299 300 301 |
# File 'lib/oci8/object.rb', line 299 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}
312 313 314 |
# File 'lib/oci8/object.rb', line 312 def class_methods @class_methods end |
#coll_attr ⇒ Object (readonly)
Returns the value of attribute coll_attr.
300 301 302 |
# File 'lib/oci8/object.rb', line 300 def coll_attr @coll_attr end |
#ind_size ⇒ Object (readonly)
Returns the value of attribute ind_size.
296 297 298 |
# File 'lib/oci8/object.rb', line 296 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}
320 321 322 |
# File 'lib/oci8/object.rb', line 320 def instance_methods @instance_methods end |
#ruby_class ⇒ Object (readonly)
named_type
293 294 295 |
# File 'lib/oci8/object.rb', line 293 def ruby_class @ruby_class end |
#typename ⇒ Object (readonly)
full-qualified object type name.
e.g.
MDSYS.SDO_GEOMETRY
290 291 292 |
# File 'lib/oci8/object.rb', line 290 def typename @typename end |
#val_size ⇒ Object (readonly)
Returns the value of attribute val_size.
295 296 297 |
# File 'lib/oci8/object.rb', line 295 def val_size @val_size end |
Class Method Details
.check_metadata(con, metadata) ⇒ Object
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/oci8/object.rb', line 431 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, false) end, # set_proc Proc.new do |val| ocidate_to_datetime(val) 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
411 412 413 |
# File 'lib/oci8/object.rb', line 411 def inspect "#<#{self.class}:#@typename>" end |
#is_collection? ⇒ Boolean
322 323 324 |
# File 'lib/oci8/object.rb', line 322 def is_collection? @coll_attr ? true : false end |