You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATEFUNCTIONupdate_categories_crates_cnt() RETURNS trigger AS $$ BEGIN IF (TG_OP ='INSERT') THEN UPDATE categories SET crates_cnt = crates_cnt +1WHERE id =NEW.category_id; return NEW; ELSIF (TG_OP ='DELETE') THEN UPDATE categories SET crates_cnt = crates_cnt -1WHERE id =OLD.category_id; return OLD; END IF; END $$ LANGUAGE plpgsql; CREATE TRIGGER trigger_update_categories_crates_cnt BEFORE INSERT ORDELETEON crates_categories FOR EACH ROW EXECUTE PROCEDURE update_categories_crates_cnt(); CREATE TRIGGER touch_crate_on_modify_categories AFTER INSERT ORDELETEON crates_categories FOR EACH ROW EXECUTE PROCEDURE touch_crate();
1
+
CREATEFUNCTIONupdate_categories_crates_cnt() RETURNS trigger AS $$ BEGIN IF (TG_OP ='INSERT') THEN UPDATE categories SET crates_cnt = crates_cnt +1WHERE id =NEW.category_id; return NEW; ELSIF (TG_OP ='DELETE') THEN UPDATE categories SET crates_cnt = crates_cnt -1WHERE id =OLD.category_id; return OLD; END IF; END $$ LANGUAGE plpgsql; CREATE TRIGGER trigger_update_categories_crates_cnt BEFORE INSERT ORDELETEON crates_categories FOR EACH ROW EXECUTE PROCEDURE update_categories_crates_cnt(); CREATE TRIGGER touch_crate_on_modify_categories AFTER INSERT ORDELETEON crates_categories FOR EACH ROW EXECUTE PROCEDURE touch_crate();
0 commit comments