Re: handing created and updated fields - Mailing list pgsql-general

From Jim C. Nasby
Subject Re: handing created and updated fields
Date
Msg-id 20050110210516.GC67721@decibel.org
Whole thread Raw
In response to Re: handing created and updated fields  (Sven Willenberger <sven@dmv.com>)
List pgsql-general
On Mon, Jan 10, 2005 at 11:16:03AM -0500, Sven Willenberger wrote:
> These could also be combined into one trigger since they are nearly
> identical anyway:
>
> CREATE FUNCTION combined_trigger() RETURNS TRIGGER AS '
> BEGIN
>    NEW.update := CURRENT_TIMESTAMP;
>    IF TG_OP = ''INSERT'' THEN
>       NEW.created := CURRENT_TIMESTAMP;
>    ELSE
>       NEW.created := OLD.created;
>    END IF;
>    RETURN NEW;
> END;
> ' LANGUAGE plpgsql;

Excellent; any idea which would perform better (combined v. separate
trigger function)?
--
Jim C. Nasby, Database Consultant               decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

pgsql-general by date:

Previous
From: Pierre-Frédéric Caillaud
Date:
Subject: Re: how to optimize my c-extension functions
Next
From: Chris
Date:
Subject: Link to development version of docs on website?