| From: | "Jim C(dot) Nasby" <decibel(at)decibel(dot)org> |
|---|---|
| To: | Sven Willenberger <sven(at)dmv(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: handing created and updated fields |
| Date: | 2005-01-10 21:05:16 |
| Message-ID: | 20050110210516.GC67721@decibel.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)decibel(dot)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?"
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chris | 2005-01-10 21:15:40 | Link to development version of docs on website? |
| Previous Message | Pierre-Frédéric Caillaud | 2005-01-10 20:45:01 | Re: how to optimize my c-extension functions |