Re: Trigger question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pat Marchant <patmarchant(at)lvcablemodem(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Trigger question
Date: 2001-12-20 23:31:47
Message-ID: 11871.1008891107@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2001-12-20 23:33:35 Re: Using a tablename as a parameter to a function.
Previous Message Philip Hallstrom 2001-12-20 23:12:20 Re: FW: Random Selection from TABLE