From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: defaults on updates |
Date: | 2003-11-01 15:24:49 |
Message-ID: | 24956.1067700289@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> writes:
> Basically, I have 5 fields, one being a PK (SERIAL), 3 with information, and
> the last one a timestamp field that will show the last time the register was
> modified (tmodif which has a DEFAULT CURRENT_TIMESTAMP).
> Now, eveytime someone modifys any, or all of the 3 information fields,
> I want the tmodif field of that register to be set to now().
This is trivial to do with a trigger --- you just need something like
NEW.lastmod := now();
RETURN NEW;
There's a complete example at the bottom of this page:
http://developer.postgresql.org/docs/postgres/plpgsql-trigger.html
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | George Essig | 2003-11-01 18:38:43 | Re: [SQL] connectby |
Previous Message | Martin Marques | 2003-11-01 13:49:17 | defaults on updates |