Order of update triggers - Mailing list pgsql-novice

From Rob Richardson
Subject Order of update triggers
Date
Msg-id 67D108EDFAD3C148A593E6ED7DCB4BBDFA351C@RADCONWIN2K8PDC.radcon.local
Whole thread Raw
Responses Re: Order of update triggers  ("Jean-Yves F. Barbier" <12ukwn@gmail.com>)
List pgsql-novice

Greetings!

 

I have a table with several triggers.  One AFTER UPDATE trigger deletes a record if a field named “result” contains -55.  A second AFTER UPDATE trigger writes data from the table into a second table that stores a history of the first table, since the first table’s records are deleted after they are used.  The customer has asked that the first trigger be changed so that an update of the results field to -55 results in a new record being added to the history table, and also the record from the main table gets deleted.

 

Does the order in which those triggers fire matter?  Does PostgreSQL guarantee that both triggers will operate on the original data?  A quick test on a copy of the production database showed that the history table got the data from the main table after I set the result to -55, and then the record was deleted from the main table.  This could be because PostgreSQL has the guarantee I want, or just because the history trigger fired before the delete trigger.  Do I need to change anything?

 

RobR

pgsql-novice by date:

Previous
From: Brent Dombrowski
Date:
Subject: Re: Total Newbie: Trouble installing postgresSQL on OS X Snow Leopard
Next
From: "Jean-Yves F. Barbier"
Date:
Subject: Re: Order of update triggers