title: How to express PostgreSQL variable as a string
body: <p>Is there any way how to express a variable in PostgreSQL as a string?</p>
  
  <p>Example:</p>
  
  <pre><code>\set table_name countries
  SELECT 'SELECT * FROM ' || CAST( :table_name, 'text' ) AS specificQuery;
  </code></pre>
  
  <p>leads to this error:</p>
  
  <pre><code>ERROR:  syntax error at or near ","
  LINE 1: SELECT 'SELECT * FROM ' || CAST( countries, 'text' ) AS specificQuery;
  </code></pre>
  
  <p>From the line sample above is obvious, that it doesn't convert "countries" to a string, but it is expressed as name of column/table.</p>
  
  <p>How do I convert it?</p>