pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Larry Rosenman <ler@lerctr.org>
To: Henry Ortega <juandelacruz@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: best way to auto-update a field when row is updated
Date: Thu, 10 Mar 2005 14:21:33 -0600
Message-ID: <200503101421.33958.ler@lerctr.org> (raw)
In-Reply-To: <2bffcc3305031012092fde7dc2@mail.gmail.com>
References: <2bffcc3305031012092fde7dc2@mail.gmail.com>

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@lerctr.org
US Mail: 3535 Gaspar Drive, Dallas, TX 75220-3611



view thread (3+ messages)  latest in thread

Message-ID: <200503101421.33958.ler@lerctr.org>
Permalink:  ../200503101421.33958.ler@lerctr.org/
Also on:    postgresql.org/message-id/200503101421.33958.ler@lerctr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ler@lerctr.org, juandelacruz@gmail.com
  Subject: Re: best way to auto-update a field when row is updated
  In-Reply-To: <200503101421.33958.ler@lerctr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox