|Subject||Re: [firebird-support] Testing Foreign Key References Before Delete?|
At 20:16 26/07/2008, you wrote:
>Hi Folks:The normal strategy is to let the exception happen, catch it and respond appropriately.
> Using current IBPP and Firebird.
> We all know Firebird will complain if a user attempts to
>delete a record that violates a foreign key reference
> Is there a way for to find out if a delete will cause
>and what tables and records will have a problem?What would a "problem" be for you? The purpose of the constraint is to constrain, i.e., to preempt something happening that would break referential integrity. If that protection is threatened, the database reacts to prevent it by throwing an exception. So it's over to you to anticipate the exceptions that would occur if the constraint were challenged and provide the means to make it right...in this case, catching the exception and telling the user the record can't be deleted because other records exist that depend on it.