From: | "Joel Burton" <jburton(at)scw(dot)org> |
---|---|
To: | Adam Haberlach <adam(at)newsnipple(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Modification times in records? |
Date: | 2000-12-08 01:54:09 |
Message-ID: | 3A2FCEC1.18511.17BA39@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 7 Dec 2000, at 1:59, Adam Haberlach wrote:
> I'm looking for a generalized way to set a field to 'now'
> whenever a record is updated.
>
> First, I started creating a plpgsql function for each table that
> I needed this for, and then using a trigger.
>
> Later, I realized that the functions were all identical, so I
> created one function, which lukily was always updating a field
> with the same name.
>
> I'm looking for a way to specify a field name when I create the
> trigger, so I can have one function and assign it to any table
> with any timestamp field and have it update automagically.
> I can't seem to get a parameter into the function. Any ideas?
There's stuff in contrib/spi that handles this (IIRC, a C function
called moddatetime or something like that.) It allows you to specify
a fieldname of the datetime field, I believe.
Plus, this should be (slightly?) faster that a PLSQL routine.
--
Joel Burton, Director of Information Systems -*- jburton(at)scw(dot)org
Support Center of Washington (www.scw.org)
From | Date | Subject | |
---|---|---|---|
Next Message | ashley | 2000-12-08 02:07:34 | Mac |
Previous Message | Ed Loehr | 2000-12-08 01:45:02 | Re: UNION within VIEW workarounds? |