Skip to content

Instantly share code, notes, and snippets.

@jlee42
Created June 15, 2012 14:54
Show Gist options
  • Select an option

  • Save jlee42/2936854 to your computer and use it in GitHub Desktop.

Select an option

Save jlee42/2936854 to your computer and use it in GitHub Desktop.
Blackboard Transact Unix - PostgreSQL Triggers
-- Create a function to preform the timestamp update.
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = now();
RETURN NEW;
END;
$$ language 'plpgsql';
-- Create a trigger to run this function prior to an UPDATE on a row.
CREATE TRIGGER update_vidimg_updated_at_time BEFORE UPDATE ON vidimg FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment