Re: protected ON DELETE CASCADE

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: Murray Hobbs <murray(at)efone(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: protected ON DELETE CASCADE
Date: 2001-08-23 13:01:51
Message-ID: 200108231302.f7ND1poa017052@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Murray Hobbs wrote:
>
>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

If the reference from D to C uses ON DELETE RESTRICT (or NO ACTION), that
should fail and thus cause the original DELETE to fail.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"For God hath not appointed us to wrath, but to obtain
salvation by our Lord Jesus Christ, Who died for us,
that, whether we wake or sleep, we should live
together with him."
I Thessalonians 5:9,10

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Oliver Elphick 2001-08-23 13:24:18 Re: integrity and inherit
Previous Message Bo Lorentsen 2001-08-23 12:43:19 Re: integrity and inherit