Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9422947624C for ; Wed, 27 Nov 2002 11:38:08 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id C47EE4766C6 for ; Wed, 27 Nov 2002 11:36:07 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 4438BD60F; Wed, 27 Nov 2002 08:36:09 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 39E605C02; Wed, 27 Nov 2002 08:36:09 -0800 (PST) Date: Wed, 27 Nov 2002 08:36:09 -0800 (PST) From: Stephan Szabo To: fred Cc: Subject: Re: CASCADE PB In-Reply-To: <20021127161904.E03F64764D2@postgresql.org> Message-ID: <20021127083341.A93967-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/282 X-Sequence-Number: 6470 On Wed, 27 Nov 2002, fred wrote: > Hello, > I use postgreSQL 7.2.3 and I have trouble on deleting. > I would like to automaticly delete line in the 'coop' table when I dlete the > line in the 'fact' table but it is not ok. > Where is my mistake ? On delete cascade goes the other direction. What you've written says that for any coop row that is deleted associated fact rows should be removed not the other way around. AFAICT your schema allows multiple fact rows to reference a single coop row which means deleting the coop row will fail unless this is the only fact row. > This is my database: > > create table coop ( > id_coop serial not null, > nom_coop varchar(50) not null, > primary key(id_coop) > ); > > create table fact ( > id_fact serial not null, > id_coop integer references coop(id_coop) on delete cascade, > date_fact timestamp not null, > montant_fact decimal(6,3), > primary key(id_fact) > ); > > Thank's for your support.