Struct oracle::sql_type::ObjectType
source · pub struct ObjectType { /* private fields */ }
Expand description
Type information about Object or Collection data type
This is for not only Object type information but also collection type information.
Examples
Gets MDSYS.SDO_GEOMETRY object type information.
let conn = Connection::connect("scott", "tiger", "")?;
let objtype = conn.object_type("MDSYS.SDO_GEOMETRY");
Gets object type infomration in query.
let conn = Connection::connect("scott", "tiger", "")?;
// conn.execute("create table location (name varchar2(60), loc sdo_geometry)", &[]);
let mut stmt = conn
.statement("select loc from location where name = '...'")
.build()?;
let rows = stmt.query(&[])?;
let objtype = if let OracleType::Object(ref objtype) = *rows.column_info()[0].oracle_type() {
objtype
} else {
panic!("Not an object type")
};
Implementations§
source§impl ObjectType
impl ObjectType
sourcepub fn package_name(&self) -> Option<&str>
pub fn package_name(&self) -> Option<&str>
Gets package name if it is a PL/SQL type.
Otherwise, None
.
sourcepub fn is_collection(&self) -> bool
pub fn is_collection(&self) -> bool
True when it is a collectoin. Otherwise false.
sourcepub fn element_oracle_type(&self) -> Option<&OracleType>
pub fn element_oracle_type(&self) -> Option<&OracleType>
Gets the Oracle type of elements if it is a collection.
Otherwise, None
.
sourcepub fn num_attributes(&self) -> usize
pub fn num_attributes(&self) -> usize
Gets the number of attributes if it isn’t a collection. Otherwise, 0.
sourcepub fn attributes(&self) -> &[ObjectTypeAttr]
pub fn attributes(&self) -> &[ObjectTypeAttr]
Gets a vector of attribute information if it isn’t a collection. Otherwise, a zero-length vector.
Examples
Prints attribute information of MDSYS.SDO_GEOMETRY
.
let conn = Connection::connect("scott", "tiger", "")?;
let objtype = conn.object_type("MDSYS.SDO_GEOMETRY")?;
for attr in objtype.attributes() {
println!("{:-20} {}", attr.name(), attr.oracle_type());
}
sourcepub fn new_object(&self) -> Result<Object>
pub fn new_object(&self) -> Result<Object>
Create a new Oracle object.
sourcepub fn new_collection(&self) -> Result<Collection>
pub fn new_collection(&self) -> Result<Collection>
Create a new collection.
Trait Implementations§
source§impl Clone for ObjectType
impl Clone for ObjectType
source§fn clone(&self) -> ObjectType
fn clone(&self) -> ObjectType
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more