view's rule -> update - Mailing list pgsql-sql

From dbalazs@homemail.com
Subject view's rule -> update
Date
Msg-id XFMail.20000730182300.balazs@napraforgo.penguinpowered.com
Whole thread Raw
List pgsql-sql
Hello,

I would liko to update a table from a view's rule:
The environment:
-------------------------------
CREATE TABLE real (name text);
CREATE TABLE alibi (name text);

CREATE TABLE alibi_view (name text);

CREATE RULE "_RETalibi_view" AS ON SELECT TO alibi_view DO INSTEAD
SELECT name FROM alibi;

CREATE RULE "_UPDalibi_view" AS ON UPDATE TO alibi_view DO INSTEAD
UPDATE real SET
name=NEW.name
--WHERE name=OLD.name
;

INSERT INTO real VALUES ('first');
INSERT INTO real VALUES ('sec');
-------------------------------

UPDATE alibi_view SET name='new' WHERE name='sec'; 
--> UPDATE 0   ...it is my problem

UPDATE alibi_view SET name='new'; 
--> UPDATE 2   ... it is OK

If I don't comment the line "where .." in the rule _UPDalibi_view
, it isn't working at all.

Can I do this with rule?
(I need the view to controll permissions.)

Thanks in advance,
DBalazs

(postgresql 7.02)


pgsql-sql by date:

Previous
From: "Robert B. Easter"
Date:
Subject: Re: Conditional rule?
Next
From: Itai Zukerman
Date:
Subject: Indices and time spans