ORACLE SDO_GEOMETRY ToString()?

CSharpened picture CSharpened · Jan 16, 2012 · Viewed 13.4k times · Source

I have a .Net system that I am writing which needs to be able to retrieve an oracle geometry field from the database. Is there any way in my SQL statement to cast the geometry type to a string so that I can deal with it on my .Net side. At the moment I cannot get the data out as it is not a valid datatype to put into my OLEDB reader so it must be converted database side.

select CS_BOUNDS from MDSYS.CS_SRS where SRID = 4326

Thanks

Answer

Vincent Malgrat picture Vincent Malgrat · Jan 16, 2012

You could use the Get_WKT method:

Returns the well-known text (WKT) format (explained in Section 6.7.1.1) of a geometry object.

The documentation gives the following example:

SELECT c.shape.Get_WKT()
  FROM cola_markets c WHERE c.name = 'cola_b';

C.SHAPE.GET_WKT()                                                               
--------------------------------------------------------------------------------
POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0)) 

The return type is CLOB.