确定哪些行在查询中导致错误
我有一个有15,000行的Oracle 18C表。作为测试,我正在尝试在其中运行以下查询:
select
--works for all rows:
--sdo_util.to_wkbgeometry(sdo_geometry(replace(sde.st_astext(shape),'LINESTRING M','LINESTRING')))
--doesn't work for all rows (the problem is caused by: SDO_UTIL.FROM_WKBGEOMETRY() ):
sdo_util.from_wkbgeometry(sdo_util.to_wkbgeometry(sdo_geometry(replace(sde.st_astext(shape),'LINESTRING M','LINESTRING'))))
from
my_table;
当我在SQL Developer中运行该查询时,它最初是没有错误的,但这仅仅是因为它仅选择前50行。
如果我尝试在所有行上运行查询(通过CTRL+END),那么它会引发一个错误:
ORA-29532: Java call terminated by uncaught Java exception: java.lang.RuntimeException: oracle.spatial.util.GeometryExceptionWithContext: Byte order can only be either BIG_ENDIAN (encoded as 0) or LITTLE_ENDIAN (encoded as 1). Found encoding 65
ORA-06512: at "MDSYS.SDO_JAVA_STP", line 68
ORA-06512: at "MDSYS.SDO_UTIL", line 6244
29532. 00000 - "Java call terminated by uncaught Java exception: %s"
*Cause: A Java exception or error was signaled and could not be
resolved by the Java code.
*Action: Modify Java code, if this behavior is not intended.
如何确定哪些特定行引起该错误?
我尝试使用 sdo_util.validate_wkbgeometry()找到问题斑点。但是,令人惊讶的是,它没有返回任何false
值。
I have an Oracle 18c table that has 15,000 rows. As a test, I'm trying to run the following query on it:
select
--works for all rows:
--sdo_util.to_wkbgeometry(sdo_geometry(replace(sde.st_astext(shape),'LINESTRING M','LINESTRING')))
--doesn't work for all rows (the problem is caused by: SDO_UTIL.FROM_WKBGEOMETRY() ):
sdo_util.from_wkbgeometry(sdo_util.to_wkbgeometry(sdo_geometry(replace(sde.st_astext(shape),'LINESTRING M','LINESTRING'))))
from
my_table;
When I run that query in SQL Developer, it initially runs without errors, but that's just because it's only selecting the first 50 rows.
If I try to run the query on all rows (via CTRL+END), then it throws an error:
ORA-29532: Java call terminated by uncaught Java exception: java.lang.RuntimeException: oracle.spatial.util.GeometryExceptionWithContext: Byte order can only be either BIG_ENDIAN (encoded as 0) or LITTLE_ENDIAN (encoded as 1). Found encoding 65
ORA-06512: at "MDSYS.SDO_JAVA_STP", line 68
ORA-06512: at "MDSYS.SDO_UTIL", line 6244
29532. 00000 - "Java call terminated by uncaught Java exception: %s"
*Cause: A Java exception or error was signaled and could not be
resolved by the Java code.
*Action: Modify Java code, if this behavior is not intended.
How can I determine what specific rows are causing that error?
I tried using SDO_UTIL.VALIDATE_WKBGEOMETRY() to find the problem blobs. But, surprisingly, it didn't return any FALSE
values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建一个函数来包装引起问题的调用并在函数中捕获异常:
然后在查询中使用它:
在以后的Oracle版本中,您可以在查询中定义函数:
Create a function to wrap the call that is causing issues and catch the exception in the function:
Then use it in your query:
In later Oracle versions, you can define the function in the query:
尝试在循环中进行操作(逐行会很慢,但是 - 如果您没有更好的耐心,请耐心等待-15.000行不会那么多...)。在代码中读取评论。
Try to do it in a loop (row-by-row which will be slow-by-slow, but - if you don't have anything better, be patient - 15.000 rows isn't that much ...). Read comments within code.
使用@MTO和@LittleFoot提供的解决方案,我能够确定以下内容:
当WKB几何形状为 3D和 - 多部分时,问题似乎会发生。
to_wkbgeometry()
函数无法将3D多部分WKB转换为SDO_GEOMETRY。我认为这可能是一个甲骨文错误。更多信息在这里:将3D多部分WKB转换为SDO_GEOMETRY
测试:
作品: 3D,单部分:
工作: 2D,多部分:
't工作: 3D,多部分:
错误:
Using the solutions provided by @MTO and @LittleFoot, I was able to determine the following:
The problem seems to happen when a WKB geometry is 3d —and— multi-part. The
to_wkbgeometry()
function can't convert 3d multi-part WKB to SDO_GEOMETRY. I think that's likely an Oracle bug.More information here: Convert 3d multi-part WKB to SDO_GEOMETRY
Testing:
Works: 3d, single-part:
Works: 2d, multi-part:
Doesn't work: 3d, multi-part:
Error: