From: Justin Wyer <justin@isogo.co.za>
To: Gary Hoffman <ghoffman@ucsd.edu>
To: pgsql-php <pgsql-php@postgresql.org>
Subject: Re: Mod_date update technique
Date: Thu, 26 Aug 2004 08:52:03 +0200
Message-ID: <412D8893.9070803@isogo.co.za> (raw)
In-Reply-To: <fc.00249f0e00f7ab7700249f0e00f7ab77.f7abac@irpsmail.ucsd.edu>
References: <fc.00249f0e00f7ab7700249f0e00f7ab77.f7abac@irpsmail.ucsd.edu>
Gary Hoffman wrote:
>I have a column named mod_date on a particular table. It has a default
>value of now() which is the create date of the row. However, I want to
>update that field with the current timestamp whenever its record is
>updated.
>
>I know how to do this using PHP by including the date() in the data I'm
>using to update the record. However, I would like to do this on the
>PostgreSQL side of the transaction. I can't figure out how to write a
>trigger or other technique to do this.
>
>
A trigger is the correct way.
>Simply asked: What is the easiest way to automatically update the mod_date
>field when the record is updated?
>
>
Check out the PostgreSQL documentation it is quite comprehensive.
http://www.postgresql.org/docs/7.4/interactive/triggers.html
Regards
Justin
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: justin@isogo.co.za, ghoffman@ucsd.edu
Subject: Re: Mod_date update technique
In-Reply-To: <412D8893.9070803@isogo.co.za>
References: <fc.00249f0e00f7ab7700249f0e00f7ab77.f7abac@irpsmail.ucsd.edu> <412D8893.9070803@isogo.co.za>
* 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