trigger ON delete - Mailing list pgsql-general

From Uroš Gruber
Subject trigger ON delete
Date
Msg-id 20021115071044.5094C7061B@citka.sir-mag.com
Whole thread Raw
Responses Re: trigger ON delete  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
Hi!

I have problems with triggers on delete and i get some kind of
loop. Here is my function.


CREATE FUNCTION nset_delete() RETURNS opaque AS \'
    DECLARE
    visits  int4;
    BEGIN

        visits := OLD.r - OLD.l + 1;
        EXECUTE \'\'DELETE FROM \'\' || TG_RELNAME || \'\' WHERE
l BETWEEN \'\' || OLD.l || \'\' AND \'\' || OLD.r || \'\';\'\';

        EXECUTE \'\'UPDATE \'\' || TG_RELNAME || \'\' SET
l=l-\'\' || visits || \'\' WHERE l>\'\' || OLD.l || \'\';\'\';
        EXECUTE \'\'UPDATE \'\' || TG_RELNAME || \'\' SET
r=r-\'\' || visits || \'\' WHERE r>\'\' || OLD.r || \'\';\'\';

    RETURN NULL;
    END;
\'  LANGUAGE \'plpgsql\';
CREATE TRIGGER nset_delete BEFORE DELETE ON nset FOR EACH ROW
EXECUTE PROCEDURE nset_delete();

When i delete some data from table nset and when it gets to
first EXECUTE (wich is DELETE) it fires trigger again and
again.

How can i solve this. Is this a bug?

--
\"Don\'t worry about people stealing your ideas.  If your ideas
are any
good, you\'ll have to ram them down people\'s throats.\"
        -- Howard Aiken


pgsql-general by date:

Previous
From: mrcampbell@mail.com (John Campbell)
Date:
Subject: problems with postgresql passwords on webmin/kylix
Next
From: Jean-Luc Lachance
Date:
Subject: Re: limiting join results