pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Murray Hobbs <murray@efone.com>
To: pgsql-sql@postgresql.org
To: pgsql-novice@postgresql.org
To: pgsql-general@postgresql.org
Subject: protected ON DELETE CASCADE
Date: Thu, 23 Aug 2001 10:01:07 +1200
Message-ID: <3B842BA3.D7E3930D@efone.com> (raw)


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



view thread (7+ messages)  latest in thread

Message-ID: <3B842BA3.D7E3930D@efone.com>
Permalink:  ../3B842BA3.D7E3930D@efone.com/
Also on:    postgresql.org/message-id/3B842BA3.D7E3930D@efone.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: murray@efone.com, pgsql-novice@postgresql.org, pgsql-general@postgresql.org
  Subject: Re: protected ON DELETE CASCADE
  In-Reply-To: <3B842BA3.D7E3930D@efone.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox