title: Problem using 'execute immediate' in PL SQL Procedure
body: <p>I am using the following code in a PL SQL procedure:</p>
  
  <pre><code>execute immediate 'select count(distinct item_type) into counter_variable
  from items where ' || field_name || ' is not null'
  </code></pre>
  
  <p>Here, </p>
  
  <p>counter_variable is declared in the declaration section of the procedure
  field_name is the IN parameter to the PL SQL procedure and the values passed will be column names from the 'items' table</p>
  
  <p>The error that I  get is 'Invalid SQL Statement' and I am not able to figure out the reason. Any ideas?</p>
  
  <p>Thanks</p>