Re: Rule problem

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Rule problem
Дата
Msg-id 19317.1023978960@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Rule problem  (Svenn Helge Grindhaug <svenn@ii.uib.no>)
Список pgsql-sql
Svenn Helge Grindhaug <svenn@ii.uib.no> writes:
> create rule a_delete as
> on delete to a do
> delete from b where id1 = old.id1;

> create rule c_delete as
> on delete to c do
> delete from a where id1 = (select id1 from b where id2 = old.id2);

The a_delete rule is run before the actual "DELETE FROM a" command,
so by the time the latter runs, the b row is gone, and no match exists.

I'd be inclined to think about doing this with foreign keys (set up
for ON DELETE CASCADE) instead of handmade rules.  If you really want
to do it by hand, triggers will probably work better than rules.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Dmitri Colebatch"
Дата:
Сообщение: Re: join question - three tables, two with foreign keys to the first
Следующее
От: Manfred Koizar
Дата:
Сообщение: Re: join question - three tables, two with foreign keys to the first