2015-02-05 55 views
-1

誰能告訴我爲什麼這樣不能編譯?我收到一個'缺少的表達式'錯誤:Oracle PL/SQL查詢不能編譯

execute immediate 'select CASE WHEN EXISTS (SELECT 1 from samples where samplecode = :samplecode and auditflag = 0 and ' || varFilterString || ') then 1 else 0 end from DUAL' 
into varResult 
using varSampleCode; 

假設變量都被正確聲明。

TIA

+0

檢查varFilterString,它可能是畸形的。具體可能是空的。 – vishad 2015-02-05 13:06:25

+0

[Oracle查詢無法編譯]的可能重複(http://stackoverflow.com/questions/28343913/oracle-query-wont-compile) – 2015-02-05 13:06:58

回答

2
execute immediate 'select count(1) from DUAL 
         where EXISTS 
         (SELECT 1 from samples 
         where samplecode = :sample code 
          and auditflag = 0 
          and ' || varFilterString || ')' 
into varResult 
using varSampleCode; 
+0

謝謝,編譯。 – 2015-02-05 13:39:04