Reputation: 11
I'm getting error when creating this trigger in PostgreSQL
DROP TRIGGER IF EXISTS districts_bdt ON districts CASCADE;
CREATE OR REPLACE FUNCTION trigger_fct_districts_bdt()
RETURNS trigger
AS $BODY$
BEGIN
DELETE GROUPS WHERE ID = OLD.UF_GROUP_ID;RETURN OLD;
END$BODY$
LANGUAGE'plpgsql' SECURITY DEFINER;
-- REVOKE ALL ON FUNCTION trigger_fct_districts_bdt() FROM PUBLIC;
CREATE TRIGGER districts_bdt
BEFORE DELETE ON districts FOR EACH ROW
EXECUTE PROCEDURE trigger_fct_districts_bdt();
This is my error
ERROR: syntax error at or near "GROUPS"
LINE 4: DELETE GROUPS WHERE ID = OLD.UF_GROUP_ID;
Upvotes: 1
Views: 809
Reputation: 498
It should be "DELETE FROM GROUPS..." instead of "DELETE GROUPS..." in line 4.
Upvotes: 1