Skip to content

Instantly share code, notes, and snippets.

@taotetek
Created October 4, 2010 02:31
Show Gist options
  • Save taotetek/609180 to your computer and use it in GitHub Desktop.
Save taotetek/609180 to your computer and use it in GitHub Desktop.
CREATE FUNCTION beam_me_up() RETURNS TRIGGER AS $$
require 'yaml'
payload = new.to_yaml
$Plans["engage"] = PL::Plan.new("NOTIFY watchers, '#{payload}'")
$Plans["engage"].exec()
$$ LANGUAGE 'plruby';
CREATE TRIGGER beam_me_up_trigger AFTER INSERT ON watched_table
FOR EACH ROW EXECUTE PROCEDURE beam_me_up();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment