db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spezifikum <i...@spezifikum.com>
Subject SQL Problem with foreign key (statement rolled back)
Date Sun, 30 Oct 2011 16:31:49 GMT
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?

Thanks a lot
Malte

Mime
View raw message