How to prevent recursion

From: "Falk Nisius" <falknisius(at)gmx(dot)de>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: How to prevent recursion
Date: 2002-08-20 08:07:26
Message-ID: NEBBJJEAELOFDDMFKJJFEEFJDIAA.falknisius@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hi,

I try to save hierarchical Data with an
id that contains strings which represent
the way through the tree. On each depth level
I can have a maxcount number of elements.

If I want move subtrees, I have to change these
id-fields. I want implement this as a RULE in the
Database, that the using application not have to
call any SQL statements in a sequence.

I tried:

CREATE RULE hangup AS
ON UPDATE TO "products"
WHERE OLD."id" != NEW."id"
DO INSTEAD
UPDATE "products" SET "id"=NEW."id" ||
substring("id",char_length(OLD."id")+1) WHERE "id" LIKE (OLD."id" || '~')

That runs definitely in recursion, and I have no idea to prevent
this. Perhaps it runs with triggers and/or Functions.

Thank for your help
Falk

Browse pgsql-sql by date

  From Date Subject
Next Message Aaron Held 2002-08-20 11:55:24 bulk imports with sequence
Previous Message Mathieu Arnold 2002-08-20 06:14:57 Re: sql subqueries problem