Re: Update-able View linked to Access - Mailing list pgsql-odbc

From Richard Broersma Jr
Subject Re: Update-able View linked to Access
Date
Msg-id 938243.53161.qm@web31814.mail.mud.yahoo.com
Whole thread Raw
In response to Re: Update-able View linked to Access  (Hiroshi Inoue <inoue@tpf.co.jp>)
Responses Re: Update-able View linked to Access  (Hiroshi Inoue <inoue@tpf.co.jp>)
List pgsql-odbc
> Could you try the following ?
> Add the CTID field of the target table of the last update rule to the
> definition of the view. In your case, try to add husband.ctid to the
> definition of vhusband.

I am still getting similar errors, only now both columns are locked.
Here is my new view definition:
--------------------------------
CREATE OR REPLACE VIEW public.vhusband (id, personctid, husbandctid, name, tiesize)  AS
SELECT
        A.id, A.ctid, B.ctid, A.name, B.tiesize
FROM
        public.person as A
INNER JOIN
        public.husband as B
ON
        A.id = B.ID
;


using OLD.husbandctid
------------------------------------
BEGIN;UPDATE "public"."vhusband"
      SET "tiesize"=3
      WHERE "id" = 14
      AND "personctid" = E'(0,63)'
      AND "husbandctid" = E'(0,42)'
      AND "name" = E'hel0'
      AND "tiesize" = 3
ROLLBACK
------------------------------------
Here is my new update rule:

CREATE OR REPLACE RULE
            vhusband_update_person
AS ON UPDATE TO
            public.vhusband
DO INSTEAD
(
    UPDATE
        public.person
    SET
        name = NEW.name
    WHERE
        id = OLD.id;
    UPDATE
        public.husband
    SET
        tiesize = NEW.tiesize
    WHERE
        id = OLD.id
    AND
        ctid = OLD.husbandctid
)
;

using NEW.husbandctid
---------------------------
BEGIN;
UPDATE "public"."vhusband"
SET    "name"=E'4'
WHERE  "id" = 14
AND    "personctid" = E'(0,63)'
AND    "husbandctid" = E'(0,42)'
AND    "name" = E'hel0'
AND    "tiesize" = 3
ROLLBACK

----------------------------
CREATE OR REPLACE RULE
                        vhusband_update_person
AS ON UPDATE TO
                        public.vhusband
DO INSTEAD
(
        UPDATE
                public.person
        SET
                name = NEW.name
        WHERE
                id = OLD.id;
        UPDATE
                public.husband
        SET
                tiesize = NEW.tiesize
        WHERE
                id = OLD.id
        AND
                ctid = new.husbandctid
)
;

Thanks for the help.

Regards,

Richard Broersma Jr.

pgsql-odbc by date:

Previous
From: Hiroshi Inoue
Date:
Subject: Re: Update-able View linked to Access
Next
From: Hiroshi Inoue
Date:
Subject: Re: Update-able View linked to Access