Oracle 18c:
In a related question, we determined:
The syntax of extracting collection elements by index is not supported in SQL.
So a query that uses this syntax will fail: (shape).sdo_ordinates(1)
,
select
(shape).sdo_ordinates(1) as startpoint_x
from
(select sdo_geometry('linestring(1 2, 3 4, 5 6)') as shape
from dual)
Error:
ORA-00904: "MDSYS"."SDO_GEOMETRY"."SDO_ORDINATES": invalid identifier
Source: Why does SHAPE.SDO_ORDINATES(1) work in PL/SQL, but not in SQL?
However, I have a query that is similar (different datatype) that succeeds when I use seemingly similar syntax: (shape).st_pointn(1)
.
select
(shape).st_pointn(1) as startpoint
from
(select treat(st_geometry.from_wkt('Linestring(1 2, 3 4, 5 6)',26917) as st_linestring) as shape
from dual)
Result:
MDSYS.ST_POINT(MDSYS.SDO_GEOMETRY(2001, 26917, MDSYS.SDO_POINT_TYPE(1, 2, NULL), NULL, NULL))
Source: Why do we need to Treat() MDSYS.ST_GEOMETRY as ST_LINESTRING to use ST_PointN(1)?
Why does (SHAPE).SDO_ORDINATES(1)
fail, but (SHAPE).ST_PointN(1)
succeeds?