1 -- NO create trigger statements. the updater will create them.
2 SELECT dropIfExists('TRIGGER', 'pkgimagebeforetrigger');
3 CREATE OR REPLACE FUNCTION _pkgimagebeforetrigger() RETURNS "trigger" AS $$
4 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
5 -- See www.xtuple.com/CPAL for the full text of the software license.
11 IF (TG_OP = 'UPDATE') THEN
13 RAISE NOTICE 'OLD.image_name %, NEW.image_name %',
14 OLD.image_name, NEW.image_name;
17 IF (NEW.image_name != OLD.image_name) THEN
18 SELECT image_id INTO _imageid FROM image WHERE image_name=NEW.image_name;
20 RAISE EXCEPTION 'Cannot change image named % because another image with that name already exists.', NEW.image_name;
24 ELSIF (TG_OP = 'INSERT') THEN
26 RAISE NOTICE 'inserting NEW.image_name %', NEW.image_name;
28 SELECT image_id INTO _imageid FROM image WHERE image_name=NEW.image_name;
30 RAISE EXCEPTION 'Cannot create new image % because another image with that name already exists.', NEW.image_name;
33 ELSIF (TG_OP = 'DELETE') THEN
40 $$ LANGUAGE 'plpgsql';
42 CREATE OR REPLACE FUNCTION _pkgimagealterTrigger() RETURNS TRIGGER AS $$
43 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
44 -- See www.xtuple.com/CPAL for the full text of the software license.
46 IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
47 IF (TG_OP = 'DELETE') THEN
54 IF (TG_OP = 'INSERT') THEN
55 RAISE EXCEPTION 'You may not create images in packages except using the xTuple Updater utility';
57 ELSIF (TG_OP = 'UPDATE') THEN
58 RAISE EXCEPTION 'You may not alter images in packages except using the xTuple Updater utility';
60 ELSIF (TG_OP = 'DELETE') THEN
61 RAISE EXCEPTION 'You may not delete images from packages. Try deleting or disabling the package.';
67 $$ LANGUAGE 'plpgsql';
69 CREATE OR REPLACE FUNCTION _pkgimageaftertrigger() RETURNS TRIGGER AS $$
70 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
71 -- See www.xtuple.com/CPAL for the full text of the software license.
73 IF (TG_OP = 'DELETE') THEN
79 $$ LANGUAGE 'plpgsql';