title: Oracle query won't compile
body: <p>I'm a bit confused. Can anyone tell me why this won't compile?</p>
  
  <pre><code>declare
  varSampleCode varchar2(80);
  varResult integer;
  
  varFilterString varchar2(80);
  
  begin
  
  varSampleCode := 'sam001';
  varFilterString := 'somecolumn=2'; 
  
  execute immediate  'select CASE WHEN EXISTS ( SELECT 1 from samples where samplecode = :varSamplecode  and auditflag = 0 and ' || varFilterString || ') then 1 else 0 end  into :varResult from DUAL'
  using IN varSampleCode, OUT varResult;
  </code></pre>
  
  <p>end;</p>
  
  <p>Assume the variables are all declared and the query itself makes sense. I get this error report:
  Error report:
  ORA-01006: bind variable does not exist
  ORA-06512: at line 12
  01006. 00000 -  "bind variable does not exist"</p>