【发布时间】:2020-06-04 21:55:39
【问题描述】:
我有带有集合类型列的递归 CTE(这里使用sys.ku$_vcnt,因为它是内置的,任何集合类型都可以重现问题)。当 where 子句中 CTE 的递归部分使用集合列时,查询失败并出现 ORA-00932: inconsistent datatypes: expected UDT got SYS.KU$_VCNT 错误。
这是最小化的示例,在实际情况下,集合内容在where 子句中进行检查。任何收集的出现似乎都足以使查询失败 - 例如非空检查,如下例所示:
with r (l, dummy_coll, b) as (
select 1 as l, sys.ku$_vcnt(), null from dual
union all
select l + 1
, r.dummy_coll
, case when r.dummy_coll is not null then 'not null' else 'null' end as b
from r
where l < 5 and r.dummy_coll is not null
)
select * from r;
如果从where 子句中删除and r.dummy_coll is not null,则查询成功。 select 子句中出现集合没有问题(b 列显示集合实际上不为空)。
为什么它不起作用以及如何强制 Oracle 从 where 子句中的先前递归级别查看集合列?
在 Oracle 11 和 Oracle 18 (dbfiddle) 中重现。
谢谢!
【问题讨论】:
标签: oracle collections oracle11g recursive-query ora-00932