Subject Re: Testing Foreign Key References Before Delete?
Author inoffensive_2006
--- In, Helen Borrie <helebor@...> wrote:
> At 20:16 26/07/2008, you wrote:
> >Hi Folks:
> >
> > 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
> >constraint.
> >
> > Is there a way for to find out if a delete will cause
> >a problem,
> The normal strategy is to let the exception happen, catch it and
respond appropriately.

Thanks Again Helen:

That's what I thought.

> >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 this case,
catching the exception and telling the user the record can't be
deleted because other records exist that depend on it.

I was wondering if, after specifying the constraints, Firebird
could be used to save me the task identify potential violations. Such
a service would offer the advantage of avoiding overlooking a constraint.

As always, I appreciate your expert advice.