According to the manual you can stack multiple queries in a RULE:

CREATE RULE name AS ON event
TO object [ WHERE condition ]
DO [ INSTEAD ] action

where action can be:

NOTHING
|
query
|
( query ; query ... )
|
[ query ; query ... ]


This seems to work provided 'query' is not "DELETE"; if it is, only the first one is executed.

My installation is Postgres 7.2.2, using the binary package shipped in Redhat 8.0

[malcolm@localhost STRUCT]$ uname -sr
Linux 2.4.18-18.8.0


Here is a test case:

CREATE TABLE A
(a_data int);

CREATE TABLE B
(b_data int);

CREATE VIEW V_AB AS
SELECT a_data,b_data FROM A,B;

CREATE RULE R_DEL_AB AS
ON DELETE TO V_AB
DO INSTEAD
(
DELETE FROM A WHERE a_data=OLD.a_data;
DELETE FROM B WHERE b_data=OLD.b_data;
);

INSERT INTO A values (1);
INSERT INTO B values (1);


test=# select * from V_AB;
a_data | b_data
--------+--------
1 | 1
(1 row)


test=#delete from v_ab;
DELETE 0

test=# select * from a;
a_data
--------
(0 rows)

test=# select * from b;
b_data
--------
1
(1 row)



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to