DELETE and UPDATE in same function with foriegn keys

Поиск
Список
Период
Сортировка
От Robert Fitzpatrick
Тема DELETE and UPDATE in same function with foriegn keys
Дата
Msg-id 1092069416.1964.68.camel@columbus.webtent.org
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: lec
Дата:
Сообщение: Re: Losing records when server hang
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: pg jdbc driver