pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jure Kodzoman <jure@plsavez.hr>
To: pgsql-sql@postgresql.org
Subject: constrains problem...
Date: Wed, 07 Dec 2005 13:38:04 +0100
Message-ID: <1133959084.5964.6.camel@localhost.localdomain> (raw)

Hy list, i would like to ask you for help.



 I have 3 tables. 


table1 has primary key 't1code' and table_rel  is 'many to many'
relation 
for table2. 


table2 primary key is 't2code'


table_rel has two fields: 't1code' and 't2code', where both of them 
together make a primary key for the relation table. This is done so no
double values exist.


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. 


Thanks a lot for your anwser! 


Yure 





view thread (2+ messages)  latest in thread

Message-ID: <1133959084.5964.6.camel@localhost.localdomain>
Permalink:  ../1133959084.5964.6.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1133959084.5964.6.camel@localhost.localdomain

 · 

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: jure@plsavez.hr
  Subject: Re: constrains problem...
  In-Reply-To: <1133959084.5964.6.camel@localhost.localdomain>

* 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