I have a table of items to sell ( ARTICULOS_TBL
) that I sort in a field of that table by family (field CODFAM
). That is to say, it is the case that there are a large number of articles that belong to the same family. In total there will be around 18,000 items.
However, it has been decided to change the classification criteria of families, since it has been found to be impractical. For this I have created a new table ( CONVERSION_TBL
) in which I do the "conversion": to each family code ( CODFAM
) I associate a new value in that table ( CODFAM_NEW
).
For this I have created a query like the following, which does not like:
UPDATE articulos_tbl A
SET A.codfam=
(SELECT CONVERSION_TBL.codfam_new
FROM CONVERSION_TBL
WHERE CONVERSION_TBL.codfam=A.codfam)
WHERE EXISTS (SELECT CONVERSION_TBL.codfam
FROM CONVERSION_TBL
WHERE CONVERSION_TBL.codfam=at_articulos_tbl.codfam);
The error he gives me is the following, but I do not understand it very well (I do not have that much level):
"Integrity cosntrains violated - parent key not found. Cause: A foreign key value has no matching primary key value Action: Delete the foreign key or add a matching priumary key."
Help ... !! and thank you very much.