From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Svenn Helge Grindhaug <svenn(at)ii(dot)uib(dot)no> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Rule problem |
Date: | 2002-06-13 14:36:00 |
Message-ID: | 19317.1023978960@sss.pgh.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Svenn Helge Grindhaug <svenn(at)ii(dot)uib(dot)no> writes:
> create rule a_delete as
> on delete to a do
> delete from b where id1 = old.id1;
> create rule c_delete as
> on delete to c do
> delete from a where id1 = (select id1 from b where id2 = old.id2);
The a_delete rule is run before the actual "DELETE FROM a" command,
so by the time the latter runs, the b row is gone, and no match exists.
I'd be inclined to think about doing this with foreign keys (set up
for ON DELETE CASCADE) instead of handmade rules. If you really want
to do it by hand, triggers will probably work better than rules.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Manfred Koizar | 2002-06-13 15:19:08 | Re: join question - three tables, two with foreign keys to the first |
Previous Message | Dmitri Colebatch | 2002-06-13 14:32:59 | Re: join question - three tables, two with foreign keys to the first |