Fortunately I have solved this problem. I think it was something about being a two field composed foreign key and updating these two fields at the same time gave some kind of error. I solve it by adding a temporary row in the referenced table with one of the fields already changed and then updating this field in the referencing table. this field has been updated, then I perform an update to the second field in the referencing table.