pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: dbalazs@homemail.com
To: pgsql-sql@postgresql.org
Subject: view's rule -> update
Date: Sun, 30 Jul 2000 18:23:00 +0200 (CEST)
Message-ID: <XFMail.20000730182300.balazs@napraforgo.penguinpowered.com> (raw)

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)



Message-ID: <XFMail.20000730182300.balazs@napraforgo.penguinpowered.com>
Permalink:  ../XFMail.20000730182300.balazs@napraforgo.penguinpowered.com/
Also on:    postgresql.org/message-id/XFMail.20000730182300.balazs@napraforgo.penguinpowered.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: dbalazs@homemail.com
  Subject: Re: view's rule -> update
  In-Reply-To: <XFMail.20000730182300.balazs@napraforgo.penguinpowered.com>
  References: <XFMail.20000730182300.balazs@napraforgo.penguinpowered.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox