How to prevent recursion - Mailing list pgsql-sql

From Falk Nisius
Subject How to prevent recursion
Date
Msg-id NEBBJJEAELOFDDMFKJJFEEFJDIAA.falknisius@gmx.de
Whole thread Raw
List 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



pgsql-sql by date:

Previous
From: Mathieu Arnold
Date:
Subject: Re: sql subqueries problem
Next
From: "Aaron Held"
Date:
Subject: bulk imports with sequence