Skip to content

Instantly share code, notes, and snippets.

@taotetek
Created October 3, 2010 15:36
Show Gist options
  • Save taotetek/608670 to your computer and use it in GitHub Desktop.
Save taotetek/608670 to your computer and use it in GitHub Desktop.
CREATE FUNCTION notify_trigger() RETURNS trigger AS $$
DECLARE
BEGIN
PERFORM pg_notify('watchers', TG_TABLE_NAME || ',id,' || NEW.id );
RETURN new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER watched_table_trigger AFTER INSERT ON watched_table
FOR EACH ROW EXECUTE PROCEDURE notify_trigger();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment