title: Postgres trigger that will insert a row into another table before it's deleted
body: <p>I have a table (entry_table) filled with various geographic location data currently used by clients for our front end Web feature service. If a user deleted their entry in the WFS it is deleted in our postgres database. I would like to create a trigger that will run an INSERT command to copy the row(roughly 25 columns of data) to a second table(historical_entry_table) so if the entries are needed again in the future they can be easily retrieved. </p>
  
  <p>Here's what I have working so far. I'm new to Triggers so I know the syntax is off. Not sure where to go from here. Im running postgres 8.4</p>
  
  <p>In the table :</p>
  
  <pre><code>CREATE TRIGGER trigger_name BEFORE DELETE 
      ON entry_table
      FOR EACH ROW
      EXECUTE PROCEDURE trigger_backup_row
  </code></pre>
  
  <p>The Function itself:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION trigger_backup_row()
      LANGUAGE SQL
      RETURNS trigger AS
  $BODY$
  BEGIN
  
  INSERT INTO historical_entry_table (col1, col2, etc) values (OLD.col1, OLD.col2, OL
  RETURN NULL:
  
  END;
  $BODY$ 
  </code></pre>