pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Jure Kodzoman <jure@plsavez.hr>
Cc: pgsql-sql@postgresql.org
Subject: Re: constrains problem...
Date: Wed, 07 Dec 2005 18:57:07 +0000
Message-ID: <43973083.3070803@archonet.com> (raw)
In-Reply-To: <1133959084.5964.6.camel@localhost.localdomain>
References: <1133959084.5964.6.camel@localhost.localdomain>

Jure Kodzoman wrote:
> What i would like to do is create a trigger or a constraint which would 
> on delete of an entry from table1 also deleted all entries containing
> code from 
> table1 in table_rel. When i try to put a constraint via PgAdmin3 it says
> it can't do 
> it because 't1code' is not primary key or unique. 
> 
> I understand the error, but what i would like to know is how to delete 
> all fields from table_rel containing the 'table1' vaule being equal to 
> 'code' being deleted from table1. 

You put two foreign keys ON table_rel, referencing table1 and table2. 
Set both to delete on cascade and you're done.

-- 
   Richard Huxton
   Archonet Ltd



view thread (2+ messages)

Message-ID: <43973083.3070803@archonet.com>
Permalink:  ../43973083.3070803@archonet.com/
Also on:    postgresql.org/message-id/43973083.3070803@archonet.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: dev@archonet.com, jure@plsavez.hr
  Subject: Re: constrains problem...
  In-Reply-To: <43973083.3070803@archonet.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