Re: Update rule on a view - what am I doing wrong

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Leif Jensen <leif(at)crysberg(dot)dk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Update rule on a view - what am I doing wrong
Date: 2013-01-18 15:58:22
Message-ID: 8004.1358524702@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Leif Jensen <leif(at)crysberg(dot)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 record per row in the top table. To be able to update on this view I have created a rule 'on update'. The rule needs to have both 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Igor Neyman 2013-01-18 16:05:28 Re: speeding up a join query that utilizes a view
Previous Message Kirk Wythers 2013-01-18 15:50:11 Re: speeding up a join query that utilizes a view