kubo / rust-oracle

Oracle driver for Rust
178 stars 43 forks source link

How to extract `Geometry` type. #79

Closed yuyang-ok closed 4 months ago

yuyang-ok commented 4 months ago

I am new to this lib,is there am example to extract geometry type. geometry often represent as WKB , EWKB etc ...

kubo commented 4 months ago

You can use SDO_UTIL.TO_WKBGEOMETRY to convert sdo_geometry type to WKB.

let sql = "select id, SDO_UTIL.TO_WKBGEOMETRY(geometry_column) from geometry_table";
for row_result in conn.query_as::<(i64, Vec<u8>)>(sql, &[])? { // fetch the second column as Vec<u8>.
    let row = row_result?;
    println!("{}, {:?}", row.0, row.1);
}

get_wkb method is available in a PL/SQL block.

yuyang-ok commented 4 months ago

thanks.