How to prevent recursion

Поиск
Список
Период
Сортировка
От Falk Nisius
Тема How to prevent recursion
Дата
Msg-id NEBBJJEAELOFDDMFKJJFEEFJDIAA.falknisius@gmx.de
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Mathieu Arnold
Дата:
Сообщение: Re: sql subqueries problem
Следующее
От: "Aaron Held"
Дата:
Сообщение: bulk imports with sequence