Order of update triggers

From: Rob Richardson <RDRichardson(at)rad-con(dot)com>
To: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Order of update triggers
Date: 2012-01-27 16:54:35
Message-ID: 67D108EDFAD3C148A593E6ED7DCB4BBDFA351C@RADCONWIN2K8PDC.radcon.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jean-Yves F. Barbier 2012-01-27 17:16:22 Re: Order of update triggers
Previous Message Brent Dombrowski 2012-01-26 21:42:54 Re: Total Newbie: Trouble installing postgresSQL on OS X Snow Leopard