Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0D63E476916 for ; Wed, 27 Nov 2002 11:52:38 -0500 (EST) Received: from www.fred.com (AMarseille-201-2-1-9.abo.wanadoo.fr [193.252.63.9]) by postgresql.org (Postfix) with SMTP id 40E3347664F for ; Wed, 27 Nov 2002 11:51:56 -0500 (EST) Received: (qmail 9282 invoked from network); 27 Nov 2002 16:51:00 -0000 Received: from fred.com (HELO there) (192.168.0.125) by 0 with SMTP; 27 Nov 2002 16:51:00 -0000 Content-Type: text/plain; charset="iso-8859-1" From: fred To: Stephan Szabo Subject: Re: CASCADE PB Date: Wed, 27 Nov 2002 17:51:00 +0100 X-Mailer: KMail [version 1.3.1] Cc: References: <20021127083341.A93967-100000@megazone23.bigpanda.com> In-Reply-To: <20021127083341.A93967-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <20021127165156.40E3347664F@postgresql.org> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/284 X-Sequence-Number: 6472 Ok, Thank you for your quick answer, I'm affraid I made a mistake on my mail. I really wanted to automaticly delete line in the 'fact' table when I delete a line in the 'fact' table. But when I suppress a line in the 'coop' table I still have the related line in the 'fact' table. Do you think there is a mistake in my sql syntaxe ? 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. On Wednesday 27 November 2002 17:36, Stephan Szabo wrote: > 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. > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster