From b4f05e5e252de387c7863b0be77049541c2ce831 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Sun, 10 Sep 2006 04:05:56 +0000 Subject: Added a script which will notify individuals of short parts via email in nearly real time git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@56 4979c152-3d1c-0410-bac9-87ea11338e46 --- sql/Pg-upgrade-2.6.17-2.6.18.sql | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sql') diff --git a/sql/Pg-upgrade-2.6.17-2.6.18.sql b/sql/Pg-upgrade-2.6.17-2.6.18.sql index 65361cc9..4cf7c9e0 100644 --- a/sql/Pg-upgrade-2.6.17-2.6.18.sql +++ b/sql/Pg-upgrade-2.6.17-2.6.18.sql @@ -10,5 +10,27 @@ CREATE SEQUENCE acctrans_entry_id_seq; ALTER TABLE acc_trans ALTER COLUMN entry_id SET DEFAULT nextval('acctrans_entry_id_seq'); UPDATE acc_trans SET entry_id = nextval('acctrans_entry_id_seq'); ALTER TABLE acc_trans ADD PRIMARY key (entry_id); + + +-- The query rewrite rule necessary to notify the email app that a new report +-- needs to be sent to the designated administrator. +-- By Chris Travers +-- chris@metatrontech.com +-- Licensed under the GNU GPL 2.0 or later at your option. See accompanying +-- GPL.txt + +CREATE OR REPLACE FUNCTION trigger_parts_short() RETURNS TRIGGER +AS +' +BEGIN + IF NEW.onhand >= NEW.rop THEN + NOTIFY parts_short; + END IF; + RETURN NEW; +END; +' LANGUAGE PLPGSQL; + +CREATE TRIGGER parts_short AFTER UPDATE ON parts +FOR EACH ROW EXECUTE PROCEDURE trigger_parts_short(); COMMIT; -- cgit v1.2.3