Pat Marchant <patmarchant(at)lvcablemodem(dot)com> writes:
> if (AttributeExists(new.updated))
> { new.updated = 'now'::datetime;}
I don't know any good way to do this in plpgsql. It'd be moderately
straightforward in C, however, since you could look at the tuple
descriptor for the relation to see if there is a field named updated.
Dunno if you want to get involved with writing your triggers in C,
but if you want to try see
http://developer.postgresql.org/docs/postgres/trigger-manager.html
Also, there's an example that's pretty darn close to what you want to do
in contrib/spi/moddatetime.c.
regards, tom lane