Rules WHERE condition - Mailing list pgsql-general

From Robert Fitzpatrick
Subject Rules WHERE condition
Date
Msg-id 1100708441.29305.7.camel@columbus.webtent.org
Whole thread Raw
Responses Re: Rules WHERE condition
List pgsql-general
I have a view that used union all to merge three tables together. I was
hoping to create a rule, one for each table using the WHERE condition of
the rule to determine which table gets updated. Is this possible?

This is what I have, assume the view here is a merge of three tables
using union all:

CREATE RULE "update_xrf" AS ON UPDATE TO "public"."viewdeterioratedlbp"
WHERE ((new.note)::text = 'Unit'::text)
DO INSTEAD (UPDATE tblxrf SET deterioration = new.deterioration;);

The note column contains a value that can trigger which table needs to
be updated. I would like to make one of these rules for each table to
update. But when I run the update, it says I have to have an
unconditional rule, is that right? Any suggestions?

ohc=# update viewdeterioratedlbp set note = 'Unit', deterioration =
'test' where xrf_id = 733;
ERROR:  cannot update a view
HINT:  You need an unconditional ON UPDATE DO INSTEAD rule.

Thanks,
--
Robert


pgsql-general by date:

Previous
From: Dawid Kuroczko
Date:
Subject: Tsearch2 and Unicode?
Next
From: Oleg Bartunov
Date:
Subject: Re: TSearch2: Problems with compound words and stop words