Re: feature request for Postgresql Rule system. - Mailing list pgsql-general

From Richard Broersma Jr
Subject Re: feature request for Postgresql Rule system.
Date
Msg-id 153739.24547.qm@web31811.mail.mud.yahoo.com
Whole thread Raw
In response to Re: feature request for Postgresql Rule system.  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
> What I was trying to explain is that all of your statements *are*
> succeeding. A WHERE clause in an UPDATE may match zero or more rows. The
> second UPDATE in your rule matches zero rows.

I see, that makes sense. I guess that my confussion was that update 0 was
not the same as success.

> You need to examine that UPDATE, because it's not doing what you expect.
> Perhaps you have several int fields in each table, and you're comparing
> against the wrong one in the WHERE clause? We need to see your table
> definitions and perhaps some sample content to help you further.

Below is my sample table, update-able view and update rule.

CREATE TABLE    public.person(
id        integer        primary key not null
                                default
                                nextval('public.person_seq'),
name        varchar(30)    unique not null);

CREATE TABLE    public.wife(
    id        integer        primary key
                    references person(id)
                    on delete cascade,
    dresssize    integer        not null);

CREATE OR REPLACE VIEW public.vwife (id, name, dresssize)  AS
SELECT A.id, A.name, B.dresssize
FROM public.person as A
INNER JOIN public.wife as B
ON A.id = B.ID;

CREATE OR REPLACE RULE vwife_update
AS ON UPDATE TO public.vwife
DO INSTEAD
(
UPDATE public.person SET name = NEW.name
WHERE id = OLD.id;
UPDATE public.wife SET dresssize = NEW.dresssize
WHERE id = OLD.id
);

Regards,

Richard Broersma Jr.

pgsql-general by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: feature request for Postgresql Rule system.
Next
From: "Joshua D. Drake"
Date:
Subject: Let's play bash the search engine