HOW TO END TRIGGER FUNCTIONS code example
Example 1: example of trigger in postgresql
CREATE or REPLACE FUNCTION increase_count()
RETURNS TRIGGER
AS
$$
BEGIN
UPDATE donor SET dcount = dcount + 1 WHERE did = NEW.did;
END
$$
LANGUAGE plpgsql;
CREATE TRIGGER update_donation_count AFTER INSERT ON donation
FOR EACH ROW
EXECUTE PROCEDURE increase_count();
Example 2: trigger in postgresql to change incoming entry
CREATE or REPLACE FUNCTION func()
RETURNS TRIGGER
AS $$
BEGIN
NEW.columnname = 0;
RETURN NEW;
END;
$$
LANGUAGE plpgsql;
CREATE TRIGGER change_incoming BEFORE INSERT on Tablename
FOR EACH ROW EXECUTE PROCEDURE func();