protected ON DELETE CASCADE - Mailing list pgsql-novice

From Murray Hobbs
Subject protected ON DELETE CASCADE
Date
Msg-id 3B842BA3.D7E3930D@efone.com
Whole thread Raw
Responses 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>)
List 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 by date:

Previous
From: Jason Earl
Date:
Subject: Re: Bad timestamp external representation
Next
From: Jason Earl
Date:
Subject: Re: Text Import