title: Parametrizing a table name
body: <p>I am working on a Postgres 8.3 database and was trying to use PL/pgSQL to create function that generates a table name based on dates input to the table:</p>
  
  <p>I have to create a series of tables that are indexed by dates for example:</p>
  
  <pre><code>drop table one_day_11_13 cascade;
  create table one_day_11_13 as
  select * from master_table where
  timestamp &lt; '2012-11-14' and timestamp &gt;= '2012-11-13';  
  
  drop table one_day_11_14 cascade;
  create table one_day_11_14 as
  select * from master_table where
  timestamp &lt; '2012-11-15' and timestamp &gt;= '2012-11-14';  
  </code></pre>
  
  <p>I was thinking the way to do this would be to create a PL/pgSQL function that took as arguments <code>('11_13', '2012-11-14', '2012-11-13')</code> for example to create the first table above.  I am having trouble coding up the appropriate EXECUTE statements.  </p>
  
  <p>What is the best way to do this kind of thing is PL/pgSQL overkill?  </p>