summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-09-10 04:05:56 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-09-10 04:05:56 +0000
commitb4f05e5e252de387c7863b0be77049541c2ce831 (patch)
tree929f8147786a06f276501f8611a34f6d2ca9ef52 /sql
parent0f4c94aed0dcd612e1598a2d15bd97858fc6e563 (diff)
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
Diffstat (limited to 'sql')
-rw-r--r--sql/Pg-upgrade-2.6.17-2.6.18.sql22
1 files changed, 22 insertions, 0 deletions
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;