Subject Re: [IBO] Handling a FK violation in OnError
Author Dany M
Antti Kurenniemi wrote:
> Helen,
> thanks, but it doesn't work, I still get the error message about the FK
> violation. If I set the RaiseException to False, then I get the "Record was
> not located for delete" error. Here's my code exactly:
> procedure TCustomerForm.CustomersQueryError(Sender: TObject;
> const ERRCODE: Integer; ErrorMessage, ErrorCodes: TStringList;
> const SQLCODE: Integer; SQLMessage, SQL: TStringList;
> var RaiseException: Boolean);
> begin
> if ERRCODE = isc_foreign_key then
> begin
> ShowMessage(rsForeignKeyViolation); // the error message
> TIB_Query(Sender).Cancel;
> // RaiseException := False; // If this is uncommented, "Record was not
> located to delete"
> end;
> end;

I think Helen gave you the answer earlier but in convoluted text. If you
want to stop IBO from further processing just do an Abort! Abort is VCL
for throwing a silent exception (reservation for faulty semantics here).

In stead of



RaiseException := false;

IBO will not raise and exception (that will be of EIB_ISCError type and
thus making noise) rather you yourself raise an excption of EAbort type
and VCL will handle that silently (I hope).

BTW, I don't know *exactly* what the method Cancel does. I never had to
use it.