开发者

sql query to determine if oracle spatial table contains curves

I've been struggling to create an Oracle SQL query that will tell me if my SDO table contains curves or arcs. I know that the sdo_elem_info contains the information I need, but I don't know how to use SQL to separate out the etype and interpretation from the sdo_elem_info.

So far, all I have is: select tbl.shape.sdo_elem_info开发者_如何学C from my_table tbl


You can use the TABLE function to extract the sdo_elem_info_array elements, then pivot that and aggregate the resulting rows to yield a row per element, with a column for offset, etype and interpretation.

Something like this should give you your query... (warning: untested)

WITH elem_info AS (
  SELECT 
    TRUNC((ROWNUM - 1) / 3, 0) element_no
  , MAX(DECODE(MOD(ROWNUM, 3), 1, t.COLUMN_VALUE, NULL)) offset
  , MAX(DECODE(MOD(ROWNUM, 3), 2, t.COLUMN_VALUE, NULL)) etype
  , MAX(DECODE(MOD(ROWNUM, 3), 0, t.COLUMN_VALUE, NULL)) interpretation
  FROM my_table tbl
  , TABLE(tbl.shape.sdo_elem_info) t
  GROUP BY TRUNC((ROWNUM - 1) / 3, 0)
)
SELECT DECODE(COUNT(*), 0, 'false', 'true')
FROM elem_info ei
WHERE ei.etype IN (1005, 2005) 
OR ei.interpretation IN (2, 4)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜