Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Insert Row Constraint error message??
Sun, Jun 25 2023 6:11 PMPermanent Link

Ian Branch

Avatar

Hi Team,
D11.3.1, latest EDB.
I have the following code covering the OnPostError for my Parts table:
{code}
procedure TPartsForm.PartsPostError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction);
begin
 //
 Action := daAbort;
 //
 if (E is EEDBError) and (EEDBError(E).ErrorCode = EDB_ERROR_CONSTRAINT) then
 begin
   //
   TaskMessageDlg('Duplicate Data Entry!', 'The record you are trying to save in the ' + DataSet.Name + ' table has duplicate data.' + sLineBreak +
     'The Part # and Bus Code combination has already been used and cannot be used again!' + sLineBreak +
     'See the following error message for details.' + sLineBreak
     + EEDBError(E).ErrorMsg, mtError, [mbOK], 0);
   //
 end
 else
   _PostError(Action, E, DataSet);
 //
end;
{code}
_PostError(Action, E, Dataset) handles other errors generally for other tables as well, but the Constraint handling is unique to particular tables.  Hence being handled here separately.  Even then I have generic constraint handling in the general handler just in case but this wasn't used either.
Anyway, what I finding  is that the constratint error is still being written to the System Events Log:
"The unique constraint PARTNO for the table Parts has been violated (Duplicate key MGND3X/A,I found)"
That is the EDB inbuilt constraint handling error message.
I had expected that my handling that error in my code would preclude it being written up in the Log.

Your thoughts/experiences/suggestions appreciated.

Regards & TIA,
Ian
Sun, Jun 25 2023 7:13 PMPermanent Link

Ian Branch

Avatar

OK.  Ignore this one.  I just realised I asked the same question 12 months ago. Smile
Brain cells fading quicker than I thought.  Frown
Image