为什么(shape).sdo_ordinates(1)语法失败,而(shape).st_pointn(1)成功?
Oracle 18c:
在一个相关问题中,我们确定了:
不支持根据索引提取收集元素的语法 在SQL。
中
因此,使用此语法的查询将失败:(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
来源:为什么shape.sdo_ordinates(1)在pl/sql中工作,而在sql?
但是,我有一个查询相似的(不同的数据类型),当我使用看似相似的语法时会成功:(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))
资料来源:为什么我们需要将()mdsys.st_ geometry视为st_linestring来使用st_pointn(1)?
为什么(shape).sdo_ordinates(1)形状).st_pointn(1)
成功?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[tl; dr]
sdo_ordinates
是mdsys.sdo_geometry
数据类型的集合属性。st_pointn
是(mdsys.st_linestring
data类型)的(超级类型)的成员函数。当您使用时:
然后,它以
object_type.member_function(gright)
的形式将SQL引擎处理语法作为对成员函数的调用,并且没有sdo_ordinates
成员>sdo_geometry
数据类型,输出为:因为没有
sdo_ordinates
成员函数在mdsys.sdo_geometry
对象上。相反,如果您使用:
然后SQL引擎将语法作为
(object_type.collection_attribute)(index)
进行处理:输出为:因为提取收集元素在SQL中不支持。
最后:
返回
st_linestring
对象类型,然后使用参数1
调用st_pointn
成员函数。之所以起作用,是因为在mdsys.st_curve
上有一个st_pointn
成员函数,它是mdsys.st_linestring
的超级类型。您可以使用以下方式看到对象的源:
然后,因为它的父:
包括声明:
db<
[TL;DR]
SDO_ORDINATES
is a collection attribute of theMDSYS.SDO_GEOMETRY
data type.ST_POINTN
is a member function of (a super-type of) theMDSYS.ST_LINESTRING
data type.When you use:
Then it the SQL engine processes the syntax as a call to a member function in the form of
object_type.member_function(argument)
and there is noSDO_ORDINATES
member function of theSDO_GEOMETRY
data type and the output is:Because there is no
SDO_ORDINATES
member function on theMDSYS.SDO_GEOMETRY
object.If instead, you use:
Then the SQL engine processes the syntax as
(object_type.collection_attribute)(index)
and the output is:Because extracting collection elements is not supported in SQL.
Finally:
Returns an
ST_LINESTRING
object type and then you call theST_POINTN
member function with the argument1
. This works because there is aST_POINTN
member function declared onMDSYS.ST_CURVE
which is the super-type ofMDSYS.ST_LINESTRING
.You can see the object's source using:
and then, for it's parent:
Which includes the declaration:
db<>fiddle here