Re: maintaining a field for every UPDATION.

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Bhuvan A <bhuvansql(at)yahoo(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: maintaining a field for every UPDATION.
Date: 2002-01-04 08:19:53
Message-ID: 20020104000537.N18170-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, 4 Jan 2002, Bhuvan A wrote:

> Well, now i would like to maintain modify_time for every updation. how
> can i? Using common plpgsql function i cant even able to refer OID
> even during UPDATION. The result is
>
> ERROR: record old has no field oid
> or
> ERROR: record new has no field oid
>
> One way: i can have seperate plpgsql function for every table and
> apply conditions accordingly. But i dont think thats the consistent
> way.
>
> how else can i maintain modify_time field ?

Would a before update trigger function something like:

begin
NEW.modify_time=now();
return NEW;
end;

do what you want?

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bjrn Lundin 2002-01-04 13:25:56 Re: SQL syntax help needed
Previous Message Katona Gabor 2002-01-04 08:08:50 Re: How to union tables and have a field with UNIQUE constraint?