title: Postgresql trigger function not working
body: <p>I'm very new to trigger function. Actually this is the first time I'm using it, and I can't pass over an issue. Here is my code:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION altitude()
    RETURNS trigger AS $$
  DECLARE
   maxaltimeter DOUBLE PRECISION;
  
  BEGIN
  
    SELECT max(altitude) INTO maxaltimeter FROM waypoints WHERE flight_id = OLD.id;
    RETURN NEW;
    UPDATE flights SET max_altimeter = NEW.maxaltimeter WHERE id=OLD.id;
  
  
  END;
  $$
  LANGUAGE plpgsql VOLATILE
  COST 100;
  
  CREATE TRIGGER set_altitude
    AFTER UPDATE OF status
    ON flights
    FOR EACH ROW
    EXECUTE PROCEDURE altitude();
  </code></pre>
  
  <p>When running UPDATE on the 'flights' table (status column) I don't get any results (but no errors too). Any ideas?
  Thank you.</p>