On 11/14/16 8:51 PM, Tom Lane wrote:
1. The impression I have is that most people write trigger functions
so that they can be shared across multiple uses.  That'd be impossible
with anonymous trigger function blocks.  So you'd be trading off merging
two commands into one, versus having to write out the whole body of the
trigger multiple times, which wouldn't be much of a win.

I've fairly frequently needed one-off triggers, usually to do some kind of data validation that wasn't suitable in a CHECK constraint. Enough so that twice now[1] I've created generic trigger functions that allow you to specify an arbitrary expression to test against NEW and OLD.

1: Second, WIP example: https://github.com/decibel/tg_sanity/blob/master/sql/tg_sanity.sql
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to