I have this code
while Rezept.TBLREZEPTZUTATList.Count > 0 do begin
Zutat := Rezept.TBLREZEPTZUTATList[0];
mgrManager.Remove(Zutat);
Rezept.TBLREZEPTZUTATList.Remove(Zutat);
end;
mgrManager.Remove(Rezept);
This works usually ok. However, I tracked the following problem down:
REZEPT is the master Record.
REZEPTZUTAT are child records. They have (among others) a FK relationship to TBLLEBENSMITTEL conssting of LEBENSMITTELCD and HERKUNFTCD.
For one record these values were malformed, so that the FK pointed to a nonexistent record. This was, because I did some recoding while FK ckecking was disabled and the recondig data contained this error.
When I tried to delete the master record of this malformed child with the code above, I got the error
Project RezeptSchnittstelle.exe raised exception class EAureliusOdbcException with message 'Error -1: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Die DELETE-Anweisung steht in Konflikt mit der REFERENCE-Einschränkung 'FK_TBLREZEPTZUTAT_TBLREZEPT_REZEPTID'. Der Konflikt trat in der xxx-Datenbank, Tabelle 'dbo.TBLREZEPTZUTAT', column 'REZEPTID' auf.'.
So it seems, as if Aurelius does not fetch the child record, altough the relation master child is ok, but child grandchild is not. This makes a bit sense, but is somewhat unexpected.
Can you comment on this?
tx Bernd