O'Reilly logo

PostgreSQL Server Programming by Jim Mlodgenski, Kirk Roybal, Hannu Krosing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. PL/pgSQL Trigger Functions

While it is generally a good practice to keep related code together and avoid "hidden" actions as part of main application code flows, there are also valid cases where it is a good practice to add some kind of general or cross-application functionality to the database using automated actions which happen each and every time a table is modified. That is, the actions are part of your data model and not your application code and you want to be sure that it is not possible to forget or bypass them in a similar way that constraints make it impossible to insert invalid data.

The tool for adding automated function calls to a table modifying event is called a trigger. Triggers are especially useful for cases where ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required