How to prevent recursion
How to prevent recursion
От:
"Falk Nisius" <falknisius@gmx.de>
Дата:
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