Hello & create rule question - Mailing list pgsql-sql

From Emils Klotins
Subject Hello & create rule question
Date
Msg-id 199903051429.QAA04937@omega.bkc.lv
Whole thread Raw
Responses Re: [SQL] Hello & create rule question  (jwieck@debis.com (Jan Wieck))
List pgsql-sql
Hello!

I have just joined this mailing list, so please do not become frustrated, if I happen to ask
something that has already been answered recently.

There is a thing, which didn't work as I expected, so maybe you could tell me, what have I done
wrong?

There are 2 tables:

museums (museum_id int2, description text, address_id int2)
addresses (address_id int2, address text);

(they are actually a bit different, the museums.museum_id & address.address_id being unique
indices with default values from sequences etc.)

I want to delete museum's address from addresses when I delete something from museums.
So I thought to do it with a rule:

CREATE RULE museumdel ON DELETE TO museums DO DELETE FROM addresses WHERE
addresses.address_id=current.address_id;

Now, when I do DELETE FROM museums, the psql monitor displays DELETE 0 and when I
check the tables, the proper entry from museums IS deleted, but the associated addresses row
is not.

What am I doing wrong?

Thanks in advance for any ideas & tips!


Emils Klotins       e-mail: emils@mail.usis.bkc.lv
Systems Manager     URL: http://www.usis.bkc.lv/
USIS Riga           7 Smilsu Str., Riga LV1050, LATVIA
......................................................
RSA PGP key published on: http://pgpkeys.mit.edu:11371

pgsql-sql by date:

Previous
From: Remigiusz Sokolowski
Date:
Subject: rules
Next
From: jwieck@debis.com (Jan Wieck)
Date:
Subject: Re: [SQL] rules