Re: Trigger question - Mailing list pgsql-novice

From Tom Lane
Subject Re: Trigger question
Date
Msg-id 11871.1008891107@sss.pgh.pa.us
Whole thread Raw
In response to Trigger question  (Pat Marchant <patmarchant@lvcablemodem.com>)
Responses Re: Trigger question
List pgsql-novice
Pat Marchant <patmarchant@lvcablemodem.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

pgsql-novice by date:

Previous
From: Philip Hallstrom
Date:
Subject: Re: FW: Random Selection from TABLE
Next
From: Tom Lane
Date:
Subject: Re: Using a tablename as a parameter to a function.