Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Update-able View linked to Access



> Please change the field name of B.ctid from hasbandctid to ctid.
> The name should be "ctid" for the driver to detect the field is for versioning.
> A.ctid isn't needed.

It works now!  However, I have a question.  If I have a view with more than two joined tables will
i need to reference the ctid from each table after the first update statement? Is this even
possible since I have to have unique column names?


View Definition
-----------------------------
CREATE OR REPLACE VIEW public.vhusband (id, ctid, name, tiesize)  AS
SELECT
	A.id, B.ctid, A.name, B.tiesize
FROM
	public.person as A
INNER JOIN
	public.husband as B
ON
	A.id = B.ID
;


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.ctid
)
;



Successful Log showing commit
-----------------------------
BEGIN;

UPDATE "public"."vhusband" 
SET    "name"=E'hello44',"tiesize"=52  
WHERE  "id" = 10 
AND    "ctid" = E'(0,47)'

SELECT "id","ctid","name","tiesize"  
FROM   "public"."vhusband"  
WHERE   "id" = 10

COMMIT

:-)

Regards,

Richard Broersma Jr.



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group