Am 31.10.2011 09:43, schrieb Knut Anders Hatlen:
Spezifikum<[email protected]> writes:
Hi,
i get the error message
"SQLIntegrityConstraintViolationException: UPDATE on table 'CDENTRY'
caused a violation of foreign key constraint 'LINKEDTO_FK' for key
(0). The statement has been rolled back."
I see, why Derby refuses to do so and i am indeed thankfull that it
does handle this, but i don't know how to get around it.
The relevent part of my table is:
Table name: CDEntry
ID=INT NOT NULL GENERATED ALWAYS AS IDENTITY(START WITH 1, INCREMENT
BY 1) PRIMARY KEY
linkedTo=INT CONSTRAINT linkedTo_FK REFERENCES CDEntry
One CDEntry line may be linked to exactly one other and quite often will be.
Sometimes that link has to be deleted, so i try:
"UPDATE CDEntry set linkedTo=0 where linkedTo=?"
"UPDATE CDEntry set linkedTo=0 where ID=?"
Executing these in any order gives me the errormessage above.
How do i solve that?
Does it work if you set linkedTo to NULL instead of 0?
Ähm, I should have known that, right? Anyway, yes, thanks a lot, it works!