我需要从内联视图中的集合中的元素创建一个集合。我尝试使用 collect 和 table 函数对集合进行解聚合并再次聚合它,但它因 ORA-03113 而失败。
下面是导致问题的查询的简化版本。
在我的实现中,我将在单个查询中加入多个级别的嵌套查询与联合,该查询应该将所有集合聚合到一个集合中。出于性能原因(昂贵的上下文切换),实现 PL/SQL 代码来聚合集合不是一种选择。
非常感谢您的反馈/建议。
脚本
SELECT BANNER FROM V$VERSION
/
CREATE OR REPLACE TYPE OBJECT_ID_TAB_T IS TABLE OF NUMBER(11);
/
SELECT OWNER, CAST(COLLECT( MULTISET(SELECT COLUMN_VALUE FROM TABLE((OBJECT_ID_LIST) ))) AS OBJECT_ID_TAB_T) AS OBJECT_ID_LIST
FROM (SELECT OWNER, OBJECT_NAME, CAST(COLLECT(OBJECT_ID) AS OBJECT_ID_TAB_T) AS OBJECT_ID_LIST
FROM ALL_OBJECTS
GROUP BY OWNER, OBJECT_NAME
)
GROUP BY OWNER
/
结果
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
5 rows selected.
Type created.
SELECT OWNER, CAST(COLLECT( MULTISET(SELECT COLUMN_VALUE FROM TABLE((OBJECT_ID_LIST) ))) AS OBJECT_ID_TAB_T) AS OBJECT_ID_LIST
FROM (SELECT OWNER, OBJECT_NAME, CAST(COLLECT(OBJECT_ID) AS OBJECT_ID_TAB_T) AS OBJECT_ID_LIST
FROM ALL_OBJECTS
GROUP BY OWNER, OBJECT_NAME
)
GROUP BY OWNER
*
Error at line 0
ORA-03113: end-of-file on communication channel
Process ID: 8000
Session ID: 154 Serial number: 164
Script Terminated on line 25.