Re: on update set default - Mailing list pgsql-general

From Tom Lane
Subject Re: on update set default
Date
Msg-id 12931.1007929740@sss.pgh.pa.us
Whole thread Raw
In response to Re: on update set default  (Doug McNaught <doug@wireboard.com>)
List pgsql-general
Doug McNaught <doug@wireboard.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

pgsql-general by date:

Previous
From: Francisco Reyes
Date:
Subject: Questions about the upcoming 7.2?
Next
From: Francisco Reyes
Date:
Subject: Re: Questions about the upcoming 7.2?