title: Correctly inserting literals in PL/PgSQL EXECUTE dynamic queries
body: <p>The following is part of a plpgsql function. The problem is that the result of <code>source_geom</code> and <code>target_geom</code> is a <code>character varying</code> data type, and therefore I need to surround the both <code>source_geom</code> and <code>target_geom</code> in quotes('  '). The thing is that in plpgsql language how I don't know I can do it.<br>
  Here's what I have at the moment:</p>
  
  <pre><code> EXECUTE 'update ' || quote_ident(geom_table) || 
          ' SET source = ' || source_geom || 
          ', target = ' || target_geom ||
          ' WHERE ' || quote_ident(gid_cname) || ' =  ' || _r.id;
  </code></pre>
  
  <p>The error that I am having is the following;</p>
  
  <pre><code>ERROR:  syntax error at or near "C03B9E3B66052D400DDEFC2BD0F24140"
  LINE 1: ...pdate track_points SET source = 0101000020E6100000C03B9E3B66...
                                                               ^
  QUERY:  update track_points SET source = 0101000020E6100000C03B9E3B66052D400DDEFC2BD0F24140, target = 0101000020E610000075690DEF83052D40F88E75CCD4F24140 WHERE ogc_fid =  2
  CONTEXT:  PL/pgSQL function "create_network" line 26 at EXECUTE statement
  </code></pre>
  
  <p>Please any suggestions how I can solve this problem.?</p>