tracking down foreign key constraint violation error

From: Robert Fitzpatrick <robert(at)webtent(dot)com>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: tracking down foreign key constraint violation error
Date: 2004-08-08 22:08:49
Message-ID: 1092002929.28620.61.camel@columbus.webtent.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2004-08-08 22:17:04 Re: CREATE FUNCTION
Previous Message Jiri Nemec 2004-08-08 21:27:49 CREATE FUNCTION