DELETE and UPDATE in same function with foriegn keys - Mailing list pgsql-general

From Robert Fitzpatrick
Subject DELETE and UPDATE in same function with foriegn keys
Date
Msg-id 1092069416.1964.68.camel@columbus.webtent.org
Whole thread Raw
List pgsql-general
I have tblhud74b that has a foreign key to tblhudunits with Restrict
Updates. I have a function that DELETEs corresponding records before
doing an UPDATE right after the DELETE statement and receive the
following error:

ERROR:  update or delete on "tblhudunits" violates foreign key
constraint "tblhudunitstblhud74b_fk" on "tblhud74b"
DETAIL:  Key (similar_group_id,sort_order)=(18,1) is still referenced
from table "tblhud74b".

It seems the DELETE is not posted before the UPDATE happens, hence the
error, right? I tried setting the Foreign Key to DEFERRABLE INITIALLY
DEFERRED, but does not seem to work. Is there a way to do this without
having to set my Foreign Key to Update instead of Restrict. That works
if I do that.

--
Robert


pgsql-general by date:

Previous
From: lec
Date:
Subject: Re: Losing records when server hang
Next
From: Kris Jurka
Date:
Subject: Re: pg jdbc driver