How do I call multiple functions in one trigger?

Started by Wei Wangabout 22 years ago3 messagesgeneral
Jump to latest
#1Wei Wang
ww220@cam.ac.uk

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Wei Wang (#1)
Re: How do I call multiple functions in one trigger?

"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

#3John Sidney-Woollett
johnsw@wardbrook.com
In reply to: Tom Lane (#2)
Re: How do I call multiple functions in one trigger?

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