我是PL / SQL的新手,我在使用Oracle中的自定义表类型创建视图时遇到问题。这些是创建的类型:
create or replace
TYPE "Control" AS OBJECT ("Date" nvarchar2(10), "R" number(7,3), "Limit(7,3);
create or replace TYPE Controls AS TABLE OF "Control";
CREATE OR REPLACE TYPE Result_typ AUTHID CURRENT_USER AS OBJECT (
"Program" varchar(10),
"ID_User" nvarchar2(25),
"Controls" Controls,
)
在DB中,我们有两种不同类型的控件(c_control,g_control)存储在不同的表中,只有很少的公共字段。我正在尝试创建一个视图,选择所有不同的控件,尽管它们的类型,所以我使用UNION子句。 这里有我的视图创建语句(通过一些微妙的更改使其更简单):
CREATE OR REPLACE VIEW "all_controls" OF Result_typ
with object IDENTIFIER ("ID_User")
as SELECT 'MYAPP' as Program,
u.user_id as "ID_User",
CAST(MULTISET(
select to_char(control_date,'yyyy-mm-dd') as "Date",
r as "R",
limit as "Limit"
from g_control
where control_date between to_date('20130310','yyyymmdd')
and to_date('20130313','yyyymmdd')
UNION
select to_char(control_date,'yyyy-mm-dd') as "Date",
r as "R",
limit as "Limit",
from control
where and control_date between to_date('20130310','yyyymmdd')
and to_date('20130313','yyyymmdd')
) AS Controls)
FROM user u
WHERE u.user_name like 'Scott';
从SQL Developer执行语句时,返回的值为“SQL错误:无法从套接字读取更多数据”。 在MULTISET中执行UNION有什么问题吗?如何选择UNION结果作为MULTISET? 提前致谢
答案 0 :(得分:3)
SELECT
CAST(MULTISET(
select '2013-01-01' a, 1 b, 1 c from dual union all
select '2013-01-01', 1, 1 from dual
) AS Controls)
FROM dual;
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 7292
Session ID: 201 Serial number: 4479
添加额外的内嵌视图似乎可以解决这个问题:
SELECT
CAST(MULTISET(
select * from
(
select '2013-01-01' a, 1 b, 1 c from dual union all
select '2013-01-01', 1, 1 from dual
)
) AS Controls)
FROM dual;
CONTROLS(Control('2013-01-01', 1, 1), Control('2013-01-01', 1, 1))
(Thanks to MichaelS at Oracle forums)
其他一些建议:
ORA-07445: exception encountered: core dump [qcsfsqacn()+105] [ACCESS_VIOLATION] [ADDR:0x4] [PC:0x12286C1] [UNABLE_TO_READ] []
之类的内容。如果此解决方法不充分,您需要联系Oracle支持人员以了解此错误。我已经查看了My Oracle Support,目前没有关于此错误的文档。