MDSYS.ST_GEOMETRY;甲骨文18c:
以下查询有效。它从 MDSYS.ST_GEOMETRY 中提取第一个点:
--Source: https://www.spdba.com.au/using-oracles-st_geometry-type-hierarchy-with-sdo_geometry-st_pointn-and-st_numpoints/
with cte as (
select treat(mdsys.st_geometry.from_wkt('LINESTRING(10 10, 20 20)',26917) as mdsys.st_linestring) as shape
from dual
)
select
(shape).st_pointn(1) as first_point
from
cte
Result:
MDSYS.ST_POINT(MDSYS.SDO_GEOMETRY(2001, 26917, MDSYS.SDO_POINT_TYPE(10, 10, NULL), NULL, NULL))
我不明白为什么我们需要Treat()
ST_GEOMETRY 超类型作为 ST_LINESTRING 子类型以便使用ST_PointN()
明白要点。
例如,如果我删除Treat(... as ST_LINESTRING)
,然后我得到一个错误:
with cte as (
select mdsys.st_geometry.from_wkt('LINESTRING(10 10, 20 20)',26917) as shape
from dual
)
select
(shape).st_pointn(1) as first_point
from
cte
Error:
ORA-00904: "MDSYS"."ST_GEOMETRY"."ST_POINTN": invalid identifier
为什么我删除时会出现此错误Treat()
?