Re: avoiding endless loop in an UPDATE trigger - Mailing list pgsql-general

From Louis-David Mitterrand
Subject Re: avoiding endless loop in an UPDATE trigger
Date
Msg-id 20010304210839.A1585@apartia.ch
Whole thread Raw
In response to avoiding endless loop in an UPDATE trigger  ("Norman J. Clarke" <norman@combimatrix.com>)
List pgsql-general
On Mon, Feb 26, 2001 at 11:53:51AM -0800, Norman J. Clarke wrote:
> Hello,
>
> I am attempting to write a trigger function or rule in pl/pgsql that runs
> on UPDATE to a table named "nodes". From inside this trigger, I would like
> to UPDATE the same "nodes" table. How can I do this without entering into
> an endless loop?

What I did is add a no_update bool to the table and test:

if new.no_update = true then
    new.no_update = false;
else
    <do your update here>
    new.no_update = true;
endif

--
Jesus is coming! Everyone look busy!

pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: INSERT ... RETURNING as Oracle
Next
From: "Oliver Elphick"
Date:
Subject: Re: INSERT ... RETURNING as Oracle