如何找到导致 ORA-01436 错误的数据
How to find the imporper data that cause ORA-01436
我有一个查询要查看数据的父子层次列表。在 运行 下面的查询中,我得到了错误 ORA-01436
。
SELECT ParentPropertyRSN, CONNECT_BY_ROOT PropertyRSN as PropertyRSN,
LEVEL, SYS_CONNECT_BY_PATH(ParentPropertyRSN, '/') Path
FROM Property
CONNECT BY PRIOR PropertyRSN = ParentPropertyRSN
order by level desc;
所以我在 CONNECT BY
子句中添加了 NOCYCLE
并获得了完整的数据列表及其层次结构路径
现在我需要的是一个查询来获取导致 ORA-01436
.
数据不准确的行的列表
你确实应该使用 NOCYCLE
来避免无限循环。最重要的是,您可以使用 CONNECT_BY_ISCYCLE
来识别有问题的行:
SELECT
ParentPropertyRSN,
CONNECT_BY_ROOT PropertyRSN as PropertyRSN,
LEVEL,
SYS_CONNECT_BY_PATH(ParentPropertyRSN, '/') Path,
CONNECT_BY_ISCYCLE Has_Cycle
FROM Property
CONNECT BY NOCYCLE PRIOR PropertyRSN = ParentPropertyRSN
ORDER BY level desc;
The CONNECT_BY_ISCYCLE
pseudocolumn returns 1
if the current row has a child which is also its ancestor. Otherwise it returns 0
.
You can specify CONNECT_BY_ISCYCLE
only if you have specified the NOCYCLE
parameter of the CONNECT BY
clause. NOCYCLE
enables Oracle to return the results of a query that would otherwise fail because of a CONNECT BY
loop in the data.
我有一个查询要查看数据的父子层次列表。在 运行 下面的查询中,我得到了错误 ORA-01436
。
SELECT ParentPropertyRSN, CONNECT_BY_ROOT PropertyRSN as PropertyRSN,
LEVEL, SYS_CONNECT_BY_PATH(ParentPropertyRSN, '/') Path
FROM Property
CONNECT BY PRIOR PropertyRSN = ParentPropertyRSN
order by level desc;
所以我在 CONNECT BY
子句中添加了 NOCYCLE
并获得了完整的数据列表及其层次结构路径
现在我需要的是一个查询来获取导致 ORA-01436
.
你确实应该使用 NOCYCLE
来避免无限循环。最重要的是,您可以使用 CONNECT_BY_ISCYCLE
来识别有问题的行:
SELECT
ParentPropertyRSN,
CONNECT_BY_ROOT PropertyRSN as PropertyRSN,
LEVEL,
SYS_CONNECT_BY_PATH(ParentPropertyRSN, '/') Path,
CONNECT_BY_ISCYCLE Has_Cycle
FROM Property
CONNECT BY NOCYCLE PRIOR PropertyRSN = ParentPropertyRSN
ORDER BY level desc;
The
CONNECT_BY_ISCYCLE
pseudocolumn returns1
if the current row has a child which is also its ancestor. Otherwise it returns0
.You can specify
CONNECT_BY_ISCYCLE
only if you have specified theNOCYCLE
parameter of theCONNECT BY
clause.NOCYCLE
enables Oracle to return the results of a query that would otherwise fail because of aCONNECT BY
loop in the data.