Re: Creating a trigger function

From: Richard Huxton <dev(at)archonet(dot)com>
To: Peter Erickson <news(at)redlamb(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Creating a trigger function
Date: 2004-04-06 19:02:12
Message-ID: 200404062002.12932.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sunday 04 April 2004 20:40, Peter Erickson wrote:
> Ok, I have determined that i can't do:
> IF NEW IS NOT NULL -- or -- IF OLD IS NOT NULL
> and that is what is causing the error.
>
> So, with this now known, is there a way to create a trigger & function
> that will allow inserts, updates, and deletes to occur while updating a
> field (mtime) in another table? At the same time, if an update takes
> place, it updates the modified time field (mtime) to the current time.
>
> I can them all to work individually by modifying the function, but I
> cant get the to all work in the same function. Do I need to create a
> trigger for inserts/updates and another for deletes?

In plpgsql, there are a number of special TG_XXX variables defined. You want
to look at TG_OP. See the manuals for details.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2004-04-06 19:11:04 Re: Storing jpgs
Previous Message Gregory Wood 2004-04-06 19:01:33 Re: Creating a trigger function