Thread: problems with rules and views

problems with rules and views

From
"Fabrizio Mazzoni"
Date:
Hi all..
I'm having problems with a view..
I created a view which uses multiple tables and this view must be updated. I
checked the docs and it explains that i need a rule to do this..
Ok i understood it..what i don't understand is how to create this rule for
an entire view. The docs explain how to create the rule for a few fields of
the view but i need that the view must be all updatable..
Considering that my view has about 35 columns, is there a way to write a
rule that does a batch update..?? Something like:

create rule xxx as
on update to yyy <-- my view
do instead
update to xxx,qqq,zzz; <-- tables from which the view is created

Or do i have to write a statement for each column...

Awaiting for your suggestions i thank you all...

Regards

fabrizio@macrongolf.com
http://macrongolf.com
http://eteampoint.com
http://macron.com


Re: problems with rules and views

From
Tom Lane
Date:
"Fabrizio Mazzoni" <fabrizio@macron.com> writes:
> Considering that my view has about 35 columns, is there a way to write a
> rule that does a batch update..?? Something like:

> create rule xxx as
> on update to yyy <-- my view
> do instead
> update to xxx,qqq,zzz; <-- tables from which the view is created

> Or do i have to write a statement for each column...

Just assume that *all* the columns are being updated.  NEW will have the
correct value (possibly the old value) for each column.  You'll probably
need one update command for each source table, but not one per column.

            regards, tom lane