protected ON DELETE CASCADE

Поиск
Список
Период
Сортировка
От Murray Hobbs
Тема protected ON DELETE CASCADE
Дата
Msg-id 3B842BA3.D7E3930D@efone.com
обсуждение исходный текст
Ответы Re: protected ON DELETE CASCADE  ("Oliver Elphick" <olly@lfix.co.uk>)
Re: [GENERAL] protected ON DELETE CASCADE  (Jan Wieck <JanWieck@Yahoo.com>)
Re: protected ON DELETE CASCADE  (Albert Reiner <e8901869@student.tuwien.ac.at>)
Список pgsql-novice
here's my problem

i have tables A, B, C, D

A <- B
A <- C <- D

i want to maintain integrity so that if A is deleted from then so is
anything referencing from B and C - no problem ON DELETE CASCADE

but if there are any D's that point back to A (through composite key in
C) i don't want the delete to go ahead - at all - i want an error
message and condition

can someone who knows the pgsql system well tell me how this is best
done

I've looked at RULE - but how do i delete the old. record (ie confirm
the delete) or conversely prevent the delete?

I've looked at TRIGGER but then i'm writing a function (in SQL?) which
is called by a trigger - again - how do i confirm or reject a delete?

or is it really the case i have to maintain the integrity externally and
write functions that deal with the children and then delete parents -
all in a single transaction - ie not use ON DELETE CASCADE, or rules, or
triggers?

and sorry for cross post but was not sure which was the best list

thanks

murray hobbs
efone.com

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

Предыдущее
От: Jason Earl
Дата:
Сообщение: Re: Bad timestamp external representation
Следующее
От: Jason Earl
Дата:
Сообщение: Re: Text Import