title: How to escape apostrophe in a db2 sql query, running within a shell script?
body: <p>I'm trying run a query that will include static columns in its output. The select statement works when I run it via the CLP, but not when I execute it within a shell script:</p>
  
  <pre><code>su - myid -c 'db2 connect to mydb;db2 -x -v "select COL1,'','',COL2,'','',COL3L from MYTABLE fetch first 10 rows only"; db2 connect reset;'
  </code></pre>
  
  <p>When I run this, the output error I get is:</p>
  
  <pre><code>SQL0104N  An unexpected token "," was found following "select COL1,".
  Expected tokens may include:  "&lt;select_sublist&gt;".  SQLSTATE=42601
  
  SQL1024N  A database connection does not exist.  SQLSTATE=08003
  </code></pre>
  
  <p>I've even tried putting the select statement in a variable and inserting that within the statement, but still the same error. Any help would be greatly appreciated. -Thx</p>