Thread: How do I call multiple functions in one trigger?

How do I call multiple functions in one trigger?

From
"Wei Wang"
Date:
Hi,

Can I call multiple functions in one trigger?
Something like this:

CREATE TRIGGER match_cond_name_generate
  BEFORE INSERT OR UPDATE
  ON public.predicate_index
  FOR EACH ROW
  EXECUTE PROCEDURE public.match_cond_name_generate();
  EXECUTE PROCEDURE public.create_predicate_table();


Postgresql won't allow me to do this. Multiple triggers won't guarantee the
order of the operations. Do I have to put everything into one single
function?


Many thanks,

Wei Wang


Re: How do I call multiple functions in one trigger?

From
Tom Lane
Date:
"Wei Wang" <ww220@cam.ac.uk> writes:
> Can I call multiple functions in one trigger?

No.  Use multiple triggers.

> Postgresql won't allow me to do this. Multiple triggers won't guarantee the
> order of the operations.

Sure they will (in recent releases anyway).  Triggers are fired
alphabetically.

            regards, tom lane

Re: How do I call multiple functions in one trigger?

From
"John Sidney-Woollett"
Date:
Tom Lane said:
> "Wei Wang" <ww220@cam.ac.uk> writes:
>> Can I call multiple functions in one trigger?

You could create a "wrapper" function that the trigger calls, which then
calls all the other functions that you need to call, in the order in which
they are defined in the wrapper function.

John Suidney-Woollett