I would like to call multiple procedures from a trigger in postgres.
CREATE TRIGGER fn_trigger_notify_ev
AFTER INSERT
ON public.event_notifications
FOR EACH ROW
EXECUTE PROCEDURE public.notify_events();
EXECUTE PROCEDURE public.notify_events_count();
I have been getting error messages after executing this command so please let me know, is it possible to call multiple procedures in a trigger?
Error message:
ERROR: syntax error at or near "public"
LINE 6: EXECUTE PROCEDURE public.notify_events_count();
^
********** Error **********
ERROR: syntax error at or near "public"
SQL state: 42601
Character: 167
Is there any method to call multiple procedures?
As commented, creating a trigger per procedure is one way. I think you could also just wrap the function calls to one procedure, like (psql example):
CREATE OR REPLACE FUNCTION do_notifies(
) RETURNS VOID AS $$
BEGIN
PERFORM notify_events();
PERFORM notify_events_count();
END; $$
LANGUAGE plpgsql;
and in your trigger just:
EXECUTE PROCEDURE public.do_notifies();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With