Subject Re: [IBO] Handling a FK violation in OnError
Author Helen Borrie
At 03:47 PM 21/09/2006, you wrote:
>Thank you, Helen. I have two additional questions: how exactly do I cancel
>the delete in the OnError, to prevent the exception from being displayed?

case ERRCODE of
ShowMessage('Cannot delete Whatever because it contains Whatever');
another_symbol: blah
RaiseException := true;

>And, is there a way to "ask" the database via IBO (or any other way) if a
>record can be deleted? The way I do it now is first ask the user if they
>really want to delete the record, then attempt to delete it and then throw
>an error if the delete fails, which is sort of clumsy.

No, because they are two altogether different things. In the first
case, it's entirely a matter between the application and the user -
it has nothing to do with the database. In the second, you're
intercepting a database error condition and handling it. Besides
that, isc_foreign_key is not the only possible exception condition
that will prevent the cancel from succeeding.