Home Postgresql listen in database function as continuously
Reply: 0

Postgresql listen in database function as continuously

user676
1#
user676 Published in April 22, 2018, 10:09 pm

I have a postgresql notify function

CREATE OR REPLACE FUNCTION public.mynotify() RETURNS trigger AS
$BODY$
BEGIN
    PERFORM pg_notify('myEvent', row_to_json(NEW)::text);
    RETURN new;
END;
$BODY$
LANGUAGE 'plpgsql;

And I set it as a trigger:

CREATE TRIGGER mytrigger
  AFTER INSERT
  ON public.mytable
  FOR EACH ROW
  EXECUTE PROCEDURE public.mynotify();

I want to listen this notifications to write another table (events) on this same database.

But I could not create a listener function. Is this possible? Or should I use a programming language like java or c#?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320004 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO