在联接中使用Oracle JSON列会导致无效的标识符

时间:2019-03-08 21:45:40

标签: json oracle join view ora-00904

我有一个如下所示的Oracle(12c)数据库:

create table t1 (
    id number, tags clob, constraint t1_chk check ( tags is json) enable
);
create table t2 (id number);

create or replace view v1 as 
select ta.id, ta.tags from t1 ta
join t1 tb on ta.id=tb.id;

这将创建两个表(t1和t2),并将t1的视图(v1)与其自身相连。

当我在t1或v1中的json列上进行一些查询时,查询将按预期工作:

 select t.id, t.tags.foo from t1 t;
 select t.id, t.tags.foo from v1 t;

由于在此示例中,我没有费心填充表,所以没有返回行,但是查询按预期进行,并返回包含ID和FOO两列的空行。

但是,如果我尝试加入t2,则查询将失败,并显示ORA-00904无效标识符错误:

 select t.id, t.tags.foo, x.id from v1 t
 join t2 x on x.id = t.id

ORA-00904: "T"."TAGS"."FOO": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:
Error at Line: 55 Column: 15

有人对如何获得这样的联接以使用json列有任何建议吗?

0 个答案:

没有答案