tracking down foreign key constraint violation error - Mailing list pgsql-general

From Robert Fitzpatrick
Subject tracking down foreign key constraint violation error
Date
Msg-id 1092002929.28620.61.camel@columbus.webtent.org
Whole thread Raw
List pgsql-general
I have a function that does varous things, I can post it if necessary.
Basically, it deletes any related similar_group_id in tblhud74b, sets
sort_order field in tblhudunits to NULL and then proceeds to re-populate
tblhud74b based on certain calculations. The function runs fine through
all loops to the end. At the end, the following ERROR appears and the
transactions in the function all fail.

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

I even tried running the script with tblhud74b empty. I can get a RAISE
NOTICE just before the END keyword in the function on the last line. No
triggers on tblhud74b, only a insert/delete after trigger on
tblhudunits, which is only updated with NULL sort_order's in the
function, inserts or deletes are being done to tblhudunits in the
function. All other edits in the function occur on tblhud74b. The only
thing I've been able to find related is the record with the Key
(similar_group_id,sort_order)=(18,10) is the first record in
tblhudunits.

Can anyone see something I am missing?
--
Robert


pgsql-general by date:

Previous
From: Jiri Nemec
Date:
Subject: CREATE FUNCTION
Next
From: Stephan Szabo
Date:
Subject: Re: CREATE FUNCTION