Skip site navigation (1) Skip section navigation (2)

Re: Help with trigger

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: "Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Help with trigger
Date: 2004-10-08 14:02:06
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On Fri, Oct 08, 2004 at 12:52:52AM -0600, Michael Fuhr wrote:

> The trigger function below, fired after inserts and updates, might
> be close to what you need.  However, it doesn't enforce the 2-tuple
> limit -- it only contains the logic to delete records based on the
> criteria you specified.  It worked in the minimal tests I performed,
> but I'd recommend doing more thorough testing before using it in
> production.

I should also point out that the trigger function I posted doesn't
deal with concurrency.  For example, if an update happens in one
transaction, and an insert happens in another transaction before
the update commits, then you could end up with two records that
should have been deleted but weren't.  The function I posted was
merely to show how one might perform the tests you need to make.

Michael Fuhr

In response to

pgsql-novice by date

Next:From: Keith WorthingtonDate: 2004-10-08 18:49:12
Subject: how to stop postmaster
Previous:From: Michael FuhrDate: 2004-10-08 06:52:52
Subject: Re: Help with trigger

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group