ORA-03113的解决方法:与CAST MULTISET的通信通道上的文件结束

时间:2012-12-10 23:01:32

标签: oracle function exception plsql multiset

下面对TEST_FUNCTION的调用因“ORA-03113:通信通道上的文件结束”而失败。 TEST_FUNCTION2中提供了一种解决方法。我把代码简化了,因为我的实际功能要复杂得多。在Oracle 11G上测试过。任何人都知道为什么第一个函数失败了?

CREATE OR REPLACE TYPE "EMPLOYEE" AS OBJECT
(
    employee_id  NUMBER(38),
    hire_date    DATE
);

CREATE OR REPLACE TYPE "EMPLOYEE_TABLE" AS TABLE OF EMPLOYEE;

CREATE OR REPLACE FUNCTION TEST_FUNCTION RETURN EMPLOYEE_TABLE IS

table1        EMPLOYEE_TABLE;
table2        EMPLOYEE_TABLE;
return_table  EMPLOYEE_TABLE;
BEGIN

SELECT CAST(MULTISET
(
    SELECT user_id, created FROM all_users
    WHERE LOWER(username) < 'm'
) AS EMPLOYEE_TABLE)
INTO table1 FROM dual;

SELECT CAST(MULTISET
(
    SELECT user_id, created FROM all_users
    WHERE LOWER(username) >= 'm'
) AS EMPLOYEE_TABLE)
INTO table2 FROM dual;

SELECT CAST(MULTISET
(    
    SELECT employee_id, hire_date
      FROM TABLE(table1)
    UNION
    SELECT employee_id, hire_date
      FROM TABLE(table2)
) AS EMPLOYEE_TABLE)
INTO return_table FROM dual;

RETURN return_table;

END TEST_FUNCTION;



CREATE OR REPLACE FUNCTION TEST_FUNCTION2 RETURN EMPLOYEE_TABLE IS

table1        EMPLOYEE_TABLE;
table2        EMPLOYEE_TABLE;
return_table  EMPLOYEE_TABLE;
BEGIN

SELECT CAST(MULTISET
(
    SELECT user_id, created FROM all_users
    WHERE LOWER(username) < 'm'
) AS EMPLOYEE_TABLE)
INTO table1 FROM dual;

SELECT CAST(MULTISET
(
    SELECT user_id, created FROM all_users
    WHERE LOWER(username) >= 'm'
) AS EMPLOYEE_TABLE)
INTO table2 FROM dual;

WITH combined AS
(
    SELECT employee_id, hire_date
      FROM TABLE(table1)
    UNION
    SELECT employee_id, hire_date
      FROM TABLE(table2)
)
SELECT CAST(MULTISET
(
    SELECT * FROM combined
) AS EMPLOYEE_TABLE)
INTO return_table FROM dual;

RETURN return_table;

END TEST_FUNCTION2;





SELECT * FROM TABLE (TEST_FUNCTION()); -- Throws exception ORA-03113.

SELECT * FROM TABLE (TEST_FUNCTION2()); -- Works

1 个答案:

答案 0 :(得分:1)

不确定您的特定示例,但这是Oracle 11.2.0.1.0中的已知错误 它与表达式中嵌套查询的级别有关。我遇到了类似的错误,同样的查询在11.2.0.2.0中运行正常(我相信11gR2补丁集2)。

https://forums.oracle.com/forums/thread.jspa?messageID=9996243