can we implement the updatable view through rule system?

From: "postgresql" <postgresql(at)db(dot)pku(dot)edu(dot)cn>
To: pgsql-hackers(at)postgresql(dot)org <pgsql-hackers(at)postgresql(dot)org>
Subject: can we implement the updatable view through rule system?
Date: 2003-05-13 09:01:42
Message-ID: 200305131645765.SM01108@gaojun
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, all
Many talks have been dealed with the updatable view.
In postgresql, It seems that we can use the powerful rule system
to implement the update, insert, delete on view.
But could we give a generalized update rule for a view?
For example, we can construct the following rule:
create table data(a int,b int,c int);
create view view_data as select * from data where c=0;

CREATE RULE view_data_update AS ON UPDATE TO view_data
DO INSTEAD
UPDATE data SET
a=(NEW.c),
b=(NEW.c);

If we submit the query" update view data set a=1 where b=2", we could not
rely on the "view_data_update" to finish the task. and I can not find how I can
find a correct generalized rule to implement the update on view.

In addition, could we just rely on the rule system to implement the updatable
view with "check option"?

Please give me some hint if you have some free time.

Best regards

Josh

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2003-05-13 09:26:34 Re: LIKE indexing proposal
Previous Message Peter Eisentraut 2003-05-13 08:04:03 Re: GUC and postgresql.conf docs