通过PLSQL连接到连接变量

时间:2014-11-01 12:10:13

标签: sql select plsql

任何人都可以解释我为什么会出现无效的标识符错误以及为什么z.cupu变量无法变量?

 ORA-00904: "Z"."CUPU": invalid identifier

select 
 (select listagg(text, ', ') within group (order by kod)
                    from cis_chyby_pu_na_uss 
                    where kod in (
                        select 
                        regexp_substr(t.stav_full, '[^,]+', 1, l.lev) split
                        from PREKLAPANIE_PU_NA_USS_HIST t, (select rownum as lev 
                                                            from dual 
                                                            connect by level <= length (trim(regexp_replace((select stav_full 
                                                                                                            from PREKLAPANIE_PU_NA_USS_HIST h 
                                                                                                            where z.cupu = h.cislo_pu)
------------------------------------------------------------------------------------------------------------------^
                                                                                                            , '[^,]+')))
                                                            ) l

                        where t.cislo_pu = z.cupu
                        and z.stav <> 100)

    )
    from zz_2202 z

1 个答案:

答案 0 :(得分:0)

with tab as 
(select 1 n from dual)
select * from tab root 
where n in (select child1.n from tab child1 
             where child1.n in (select child2.n from tab child2 
                                 where child2.n = root.n));

with tab as 
(select 1 n from dual)
select (select * from tab child1 where child1.n = root.n)
from tab root;  

with tab as 
(select 1 n from dual)
select (select * from (select * from tab child2 where child2.n = root.n))
from tab root;

ERROR

因此,在选择列表中嵌套的限制似乎等于1.

  

Oracle在嵌套子查询时执行相关子查询   引用一个引用父语句的表中的列   子查询之上的级别。父语句可以是SELECT,   子查询嵌套的UPDATE或DELETE语句。一个   相关子查询在概念上针对每一行进行一次评估   由父语句处理。但是,优化器可能会选择   将查询重写为连接或使用其他一些技术   制定在语义上等效的查询。 Oracle解决了   子查询中的非限定列,通过查看名为的表来查找   子查询,然后在父语句中命名的表中。