Re: best way to auto-update a field when row is updated

From: Larry Rosenman <ler(at)lerctr(dot)org>
To: Henry Ortega <juandelacruz(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: best way to auto-update a field when row is updated
Date: 2005-03-10 20:21:33
Message-ID: 200503101421.33958.ler@lerctr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thursday 10 March 2005 02:09 pm, Henry Ortega wrote:
> I have the following table
>
> FIELD_A | FIELD_B | TSTAMP
> ---------------------------------------------------------------------------
>----------------------------- x y
> 2005-03-10 14:56:47.456431
>
> TSTAMP = not null default now()
>
> What's the best way to always auto-update TSTAMP to it's
> default value whenever the row gets updated?
> (e.g. update TABLENAME set FIELD_A='zzz' where FIELD_A='x';
> should automatically set TSTAMP to now)
>
trigger on update/insert.

> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 214-351-4152 E-Mail: ler(at)lerctr(dot)org
US Mail: 3535 Gaspar Drive, Dallas, TX 75220-3611

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2005-03-10 20:35:48 Re: best way to auto-update a field when row is updated
Previous Message Henry Ortega 2005-03-10 20:09:42 best way to auto-update a field when row is updated