title: How to query objects within range by longitude/latitude? (ArcGis sde.st_geometry, Oracle)
body: <p>I have a data table like this:</p>
  
  <pre><code>CREATE TABLE devices (id INTEGER PRIMARY KEY NOT NULL, shape SDE.ST_GEOMETRY)
  </code></pre>
  
  <p>For a given GPS location (latitude, longitude), I'd like to query all objects within 50 meters. How to achieve that?</p>
  
  <p>I'm so frustrated in searching many many docs, and no result till now.</p>
  
  <p>One idea is to use the function on Eris (company who developed ArcGis) web site:</p>
  
  <pre><code>sde.st_distance (g1 sde.st_geometry, g2 sde.st_geometry)
  </code></pre>
  
  <p>However the return value is described as "double precision", how to use that with GPS?
  And many other functions (e.g. Oracle built-in functions) work with different type I think (SDO_GEOMETRY). <a href="http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#geodatabases/st_distance.htm" rel="nofollow">http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#geodatabases/st_distance.htm</a></p>
  
  <p>Another idea is to create an ArcGis shape object (sde.st_geometry), a circle object with 50 meters radius and use sde.st_contains function (<a href="http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#geodatabases/st_contains.htm" rel="nofollow">http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#geodatabases/st_contains.htm</a>). However, how can I create such a geometry object?</p>
  
  <p>And all the geo object creation SQL (INSERT...) in the example fails on my Oracle DB, with error liek "wrong number or types of arguments in call to 'ST_POINT'.</p>
  
  <p>I think this should be a fundamental requirement in most GPS based applications.
  Sorry for the mess...</p>
  
  <p>Edit:
  I found there's oracle functions which deals with geo data, but not sure whether this works with SDE.ST_GEOMETRY object?
  <a href="http://docs.oracle.com/cd/B12037_01/appdev.101/b10826/sdo_complex_queries.htm#sthref2131" rel="nofollow">http://docs.oracle.com/cd/B12037_01/appdev.101/b10826/sdo_complex_queries.htm#sthref2131</a></p>