1 -- NO create trigger statements. the updater will create them.
3 SELECT dropIfExists('TRIGGER', 'pkgreportbeforetrigger');
4 CREATE OR REPLACE FUNCTION _pkgreportbeforetrigger() RETURNS "trigger" AS $$
5 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
6 -- See www.xtuple.com/CPAL for the full text of the software license.
12 IF (TG_OP = 'UPDATE') THEN
14 RAISE NOTICE 'update OLD % %, NEW % %',
15 OLD.report_name, OLD.report_grade, NEW.report_name, NEW.report_grade;
18 IF (NEW.report_name != OLD.report_name) THEN
19 SELECT report_id INTO _reportid
21 WHERE ((report_name=NEW.report_name)
22 AND (report_grade=NEW.report_grade));
24 RAISE EXCEPTION 'Cannot change report % % because another report with that name and grade already exists.', NEW.report_name, NEW.report_grade;
28 ELSIF (TG_OP = 'INSERT') THEN
30 RAISE NOTICE 'insert NEW % %', NEW.report_name, NEW.report_grade;
32 SELECT report_id INTO _reportid
34 WHERE ((report_name=NEW.report_name)
35 AND (report_grade=NEW.report_grade));
37 RAISE EXCEPTION 'Cannot create new report % % because another report with that name and grade already exists.', NEW.report_name, NEW.report_grade;
40 ELSIF (TG_OP = 'DELETE') THEN
47 $$ LANGUAGE 'plpgsql';
49 CREATE OR REPLACE FUNCTION _pkgreportalterTrigger() RETURNS TRIGGER AS $$
50 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
51 -- See www.xtuple.com/CPAL for the full text of the software license.
53 IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
54 IF (TG_OP = 'DELETE') THEN
61 IF (TG_OP = 'INSERT') THEN
62 RAISE EXCEPTION 'You may not create report definitions in packages except using the xTuple Updater utility';
64 ELSIF (TG_OP = 'UPDATE') THEN
65 RAISE EXCEPTION 'You may not alter report definitions in packages except using the xTuple Updater utility';
67 ELSIF (TG_OP = 'DELETE') THEN
68 RAISE EXCEPTION 'You may not delete report definitions from packages. Try deleting or disabling the package.';
74 $$ LANGUAGE 'plpgsql';
76 CREATE OR REPLACE FUNCTION _pkgreportaftertrigger() RETURNS TRIGGER AS $$
77 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
78 -- See www.xtuple.com/CPAL for the full text of the software license.
80 IF (TG_OP = 'DELETE') THEN
86 $$ LANGUAGE 'plpgsql';