Re: CASCADE PB

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: fred <fred(at)skyturn(dot)net>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: CASCADE PB
Date: 2002-11-27 16:36:09
Message-ID: 20021127083341.A93967-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2002-11-27 16:42:43 Re: pg_restore error: function plpgsql_call_handleralready exists with same argument types
Previous Message fred 2002-11-27 16:18:08 CASCADE PB