title: Adding quotes around a date variable at run time - SQL / PL-SQL
body: <p>I am using this line in my PL-SQL procedure script: </p>
  
  <pre><code>l_query := REPLACE(l_query,'&lt;REF_D&gt;',  REF_D) 
  </code></pre>
  
  <p>this results in: </p>
  
  <pre><code>select sum(rec_count) from mt_table_status where table_id = 8942 and ref_d = 15.06.17
  </code></pre>
  
  <p>but SQL is not executing it because the REF_D is not in inverted commas ('') </p>
  
  <p>How do I enclose my date variable in quotes? </p>
  
  <p>P.S. I have tried QUOTENAME but I get an error saying: </p>
  
  <blockquote>
    <p>identifier quotename must be declared</p>
  </blockquote>
  
  <p>As always.. any help is much appreciated..</p>