Problem with Oracle (Spatial Geometry) query

被刻印的时光 ゝ 提交于 2019-12-13 02:43:20

问题


I'm trying to form a query that returns a list of entities within a given rectangle, using SDO_WITHIN_DISTANCE. The query I've made seems like it should work, but Oracle is giving me some strange errors. Here's the query:

SELECT * 
FROM TBLENTITYLOCATION TL
      INNER JOIN TBLENTITY TE 
      ON TE.ENTITYID=TL.ENTITYID  
WHERE SDO_WITHIN_DISTANCE (TL.GEOLOCATION
                           , SDO_GEOMETRY (2003
                                         , NULL
                                         , NULL
                                         , SDO_ELEM_INFO_ARRAY(1, 1003, 3)
                                         , SDO_ORDINATE_ARRAY(41, -73, 36, -82)
                              ), 'DISTANCE=10 UNIT=M'
                          ) = 'TRUE' 
AND  TL.LOCATIONDATETIME= (select MAX(LOCATIONDATETIME) 
                           FROM TBLENTITYLOCATION 
                           WHERE  ENTITYID = TE.ENTITYID)

The error is as follows:

ORA-29902: error in executing ODCIIndexStart() routine
ORA-13208: internal error while evaluating [window SRID does not match layer SRID] operator
ORA-06512: at MDSYS.SDO_INDEX_METHOD_10I", line 286

OERR says:

29902. 00000 -  "error in executing ODCIIndexStart() routine"
*Cause:    The execution of ODCIIndexStart routine caused an error.
*Action:   Examine the error messages produced by the indextype code and take appropriate action.

Thanks for any help or ideas.


回答1:


The ORA-13208 error is the prime one here. The TL.GEOLOCATION needs a matching value in the SRID (second parameter of the SDO_GEOMETRY)

See if the response here helps you out.




回答2:


Gary Myers provided correct answer, let me augment it. If you don't know which SRID is used by your table, do a query:

select SRID from USER_SDO_GEOM_METADATA where TABLE_NAME='TBLENTITYLOCATION' and COLUMN_NAME='TBLENTITYLOCATION'

Also, to query for objects which are within a rectangle, you don't need SDO_WITHIN_DISTANCE operator. Instead, use SDO_RELATE with mask=ANYINTERACT. See http://docs.oracle.com/cd/B12037_01/appdev.101/b10826/sdo_operat.htm#i78531 for more details.



来源:https://stackoverflow.com/questions/3259226/problem-with-oracle-spatial-geometry-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!