Restrictions of channel arg of pg_notofy - Mailing list pgsql-sql

From Axel Rau
Subject Restrictions of channel arg of pg_notofy
Date
Msg-id 023C223F-4FC9-4E9E-A8C6-17F491358FA7@Chaos1.DE
Whole thread Raw
Responses Re: Restrictions of channel arg of pg_notofy  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Hi everyone!

Can the channel argument derived from the NEW pseudo arg of an INSERT TRIGGER?
In the following trigger function, the
    PERFORM pg_notify(fac);
does not work (LISTEN in psql shows no notification).

Any help welcome.
Thanks, Axel

CREATE TRIGGER new_event_trigger AFTER INSERT OR UPDATE ON syslog.event
    FOR EACH ROW EXECUTE PROCEDURE syslog.new_event_action();


CREATE OR REPLACE FUNCTION syslog.new_event_action() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    DECLARE
        fac TEXT := format('f0%s', NEW.facility);
    BEGIN
    IF NEW.facility > 9 THEN
        fac := format('f%s', NEW.facility);
    END IF;
    IF NEW.facility = 8 THEN
        INSERT INTO pf_event (id) VALUES (NEW.id);
    END IF;
    PERFORM pg_notify(fac);
    RETURN NEW;
    END;
$$;

---
PGP-Key:29E99DD6  ☀  computing @ chaos claudius




pgsql-sql by date:

Previous
From: Max Lipsky
Date:
Subject: Re: Problem in
Next
From: Tom Lane
Date:
Subject: Re: Restrictions of channel arg of pg_notofy