Re: Update rule on a view - what am I doing wrong - Mailing list pgsql-general

From Tom Lane
Subject Re: Update rule on a view - what am I doing wrong
Date
Msg-id 8004.1358524702@sss.pgh.pa.us
Whole thread Raw
In response to Update rule on a view - what am I doing wrong  (Leif Jensen <leif@crysberg.dk>)
List pgsql-general
Leif Jensen <leif@crysberg.dk> writes:
>    I have been fighting a problem with an update rule on a view. I have a view that combines two tables where the
'sub'table (scont) can have several rows per row in the 'top' table (icont). The view combines these to show only one
recordper row in the top table. To be able to update on this view I have created a rule 'on update'. The rule needs to
haveboth UPDATE, DELETE, and INSERT commands. Is this not possible or am I doing something else wrong ? 

Multiple commands in a view rule are pretty squishy --- I think the
earlier statements in your rule list are probably changing the view's
output and thus affecting the behavior of later statements.  You're
also going to have lots of unpleasant surprises as soon as you try
to use any volatile functions (eg nextval()) with this.

9.1 has INSTEAD OF triggers, so I'd strongly recommend seeing if you can
use those instead of rules.

            regards, tom lane


pgsql-general by date:

Previous
From: Kirk Wythers
Date:
Subject: Re: speeding up a join query that utilizes a view
Next
From: Igor Neyman
Date:
Subject: Re: speeding up a join query that utilizes a view