title: how to deal with single quotation marks in postgresql functions
body: <p>I have a pg function which need to be deal with single quotation marks.</p>
  
  <pre><code>create or replace function deal_null_value(in user_id numeric) returns integer as
  $body$
      declare
          part_num integer;
          sql_str character varying;
      begin
          sql_str := '
          select b.num from (
              select regexp_split_to_table(together,E',\\s*') as together,
              count(id) as num
              from inc_info t
              where
              t.registime&gt;=to_timestamp('2011-10-01 00:00:00','yyyy-MM-dd HH:mi:ss')
              and t.registime&lt;=to_timestamp('2011-10-31 23:59:59','yyyy-MM-dd HH:mi:ss')
              group by together_person
          ) as b 
          where cast(b.together as integer) = ' || user_id;
  
      EXECUTE sql_str into part_num;
      return part_num;
      end;
  $body$
  LANGUAGE 'plpgsql'
  </code></pre>
  
  <p>you see I have some single quotation marks.</p>
  
  <pre><code>regexp_split_to_table(together,E',\\s*')
  to_timestamp('2011-10-01 00:00:00','yyyy-MM-dd HH:mi:ss')
  </code></pre>
  
  <p>I want to use $$ to instead of ' and I want to use quote_literal function, how can I use it?</p>
  
  <p>Thanks in advance! </p>