title: PostgreSQL syntax error when using EXECUTE in Function
body: <p>I'm trying to create a function which references a temporary table in PostgreSQL 8.4.  Based on my research it seems the best way to do this is to use the <code>EXECUTE</code> command to execute my query from a defined string.</p>
  
  <p>Unfortunately I'm getting an odd syntax error when trying to create the function.</p>
  
  <p>My current function definition is as follows:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION example() RETURNS void AS $$
    EXECUTE 'INSERT INTO table1 (col1, col2, col3) SELECT col1, col2, col3 from temp_table';
  $$ LANGUAGE SQL;
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <pre><code>ERROR:  syntax error at or near "'INSERT INTO table1 (col1, col2, col3) SELECT col1, col2, col3 from temp_table'"
  LINE 2:   execute 'INSERT INTO table1 (col1, col2, col3) SELECT col1...
  </code></pre>
  
  <p>It seems I get the same error regardless of what is actually in the string literal.</p>
  
  <p>My questions are, 1) what is the correct syntax for using the EXECUTE feature, and 2) is there a better way to write a function like this that references a temporary table?</p>