title: Pl/pgSQL there is no parameter $1 in EXECUTE statement
body: <p>I can't solve this:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION dpol_insert(
      dpol_cia integer, dpol_tipol character, dpol_nupol integer,
      dpol_conse integer,dpol_date timestamp)
    RETURNS integer AS
  $BODY$
      DECLARE tabla text := 'dpol'||EXTRACT (YEAR FROM $5::timestamp);
  BEGIN
      EXECUTE '
      INSERT INTO '|| quote_ident(tabla) ||' 
      (dpol_cia, dpol_tipol, dpol_nupol, dpol_conse, dpol_date) VALUES ($1,$2,$3,$4,$5)
      ';
  END
  $BODY$
    LANGUAGE plpgsql VOLATILE
    COST 100;
  </code></pre>
  
  <hr>
  
  <p>When trying </p>
  
  <pre><code>SELECT dpol_insert(1,'X',123456,1,'09/10/2013')
  </code></pre>
  
  <p>return next message:</p>
  
  <pre><code>ERROR:  there is no parameter $1
  LINE 3: ...tipol, dpol_nupol, dpol_conse, dpol_date) VALUES ($1,$2,$3,$...
                                                               ^
  QUERY:  
      INSERT INTO dpol2013 
      (dpol_cia, dpol_tipol, dpol_nupol, dpol_conse, dpol_date) VALUES ($1,$2,$3,$4,$5)
  
  CONTEXT:  PL/pgSQL function "dpol_insert" line 4 at EXECUTE statement
  </code></pre>
  
  <p><em><strong></em>***<em></strong> Error <strong></em>**<em>*</em></strong></p>
  
  <pre><code>ERROR: there is no parameter $1
  SQL state: 42P02
  Context: PL/pgSQL function "dpol_insert" line 4 at EXECUTE statement
  </code></pre>