Обсуждение: How do I call multiple functions in one trigger?

Поиск
Список
Период
Сортировка

How do I call multiple functions in one trigger?

От
"Wei Wang"
Дата:
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?

От
Tom Lane
Дата:
"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?

От
"John Sidney-Woollett"
Дата:
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