考虑以下脚本:
CREATE TYPE t1 AS TABLE OF VARCHAR2(10);
/
CREATE TYPE t2 AS VARRAY(10) OF VARCHAR2(10);
/
CREATE TABLE t (
id NUMBER(10),
t1 t1,
t2 t2
)
NESTED TABLE t1 STORE AS t1_nt;
INSERT INTO t VALUES (1, NULL, NULL);
INSERT INTO t VALUES (2, t1('abc'), t2('abc'));
SELECT * FROM t WHERE 'abc' MEMBER OF t1;
SELECT * FROM t WHERE 'abc' MEMBER OF t2;
最后两个SELECT
语句的输出为
ID T1 T2
-------------------
2 [abc] [abc]
ORA-00932: inconsistent datatypes: expected UDT got
SQL_XQMZQAMSETXZLGIEEEEBUTFWF.T2
member_condition是成员资格条件,用于测试元素是否为嵌套表的成员。如果expr等于指定的嵌套表或varray的成员,则返回值为TRUE。
我在做什么错了?
答案 0 :(得分:0)
这是一个文档错误,请参见此AskTom question and answer。
一种解决方法是运行此查询:
SELECT *
FROM t
WHERE EXISTS (
SELECT 1 FROM TABLE(t2) WHERE column_value = 'abc'
)
I've written up a blog post showing emulations of all the multiset conditions and operators,以防其他人觉得有用。