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)