Re: constrains problem...

From: Richard Huxton <dev(at)archonet(dot)com>
To: Jure Kodzoman <jure(at)plsavez(dot)hr>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: constrains problem...
Date: 2005-12-07 18:57:07
Message-ID: 43973083.3070803@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Aaron Koning 2005-12-07 19:36:55 Re: Help on function creating
Previous Message Tom Lane 2005-12-07 15:11:56 Re: How to increase row deletion efficiency?