Update rule on a view - what am I doing wrong

From: Leif Jensen <leif(at)crysberg(dot)dk>
To: pgsql-general(at)postgresql(dot)org
Subject: Update rule on a view - what am I doing wrong
Date: 2013-01-18 14:19:07
Message-ID: 896712.17467.1358518747042.JavaMail.root@quick
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

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 ?

In the included sql script I have tried to show the problem. When the final update statement is executed, I get a 'duplicate key violation' on a record that has never been there.

I am using PostgreSQL version 9.1.7 (running on Linux/Ubuntu 12.04). What am I doing wrong ?

Please help,

Leif

Attachment Content-Type Size
test.sql text/x-sql 1.3 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2013-01-18 14:48:58 Re: proposal: fix corner use case of variadic fuctions usage
Previous Message Igor Neyman 2013-01-18 14:10:27 Re: speeding up a join query that utilizes a view