Re: on update set default

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Doug McNaught <doug(at)wireboard(dot)com>
Cc: "Ben-Nes Michael" <miki(at)canaan(dot)co(dot)il>, pgsql-general(at)postgresql(dot)org
Subject: Re: on update set default
Date: 2001-12-09 20:29:00
Message-ID: 12931.1007929740@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Doug McNaught <doug(at)wireboard(dot)com> writes:
>> Im want that on each insert, update to a table the column:
>> changed_on TIMESTAMP DEFAULT now()
>> will be set to now();

> An AFTER trigger to do this should be pretty easy.

It had better be a BEFORE trigger; AFTER is too late to affect the row
that will be stored. But I agree that this should be a very trivial
trigger to write. The body need be no more than

new.changed_on := now();
return new;

> Why don't you post
> what you've tried and we'll see where you went wrong?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-12-09 20:30:57 Re: Questions about the upcoming 7.2?
Previous Message Francisco Reyes 2001-12-09 17:24:52 Questions about the upcoming 7.2?