2014-11-01 84 views
0

任何人都可以解釋我爲什麼我得到無效的標識符錯誤,爲什麼不能變量z.cupu可達?到達變量通過PLSQL連接

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 
+0

在你的問題中沒有PL/SQL – 2014-11-01 12:35:34

回答

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)); 

OK

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

OK

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在子查詢中解決 不合格的列,方法是查看子查詢中名爲 的表,然後查找父語句中指定的表中的表。