Subject Re: [firebird-support] Is using SELECT COUNT (*) in a stored procedure a bad idea? (Once Again)
Author Martijn Tonies
Hi Alexandre,

> > > Q: Is there any way to re-write this stored procedure to quit
> >the
> > > table after it finds the first occurrence where the ACTIVITY_TYPE_CODE
> > > 'N'?
> > >
> > > Q: Is there a better way to trap for FK violations in my interface and
> > > use stored procedures at all?
> >
> >Actually, I simply do a:
> >
> >try
> >.. do delete
> >except
> > on E:Exception
> > do if Pos('FK_<myforeignkeyname>', E.Message) > 0
> > then ... show message for this particular foreign key and rollback
> >everything
> >
> I presume he is not using foreign keys... since he wants to check for the
> existance of data in each child table....
> Or he does it just to show the proper message ???
> By the way... I don't like to show a message based on text (like you did)
> but the exception number changes on each "drop/create exception" so there
> is no other way... I think will be realy good if FB could store an "error
> number" in the user exception and in FK violations, this error should be
> constant to be incorporated in the client app...
> Anyone has any suggestions about it ???

Well, it would be nice to link a particular "EXCEPTION" to a certain FK
violation. But, the exception should be able to store longer messages than
78 characters. At the client side, you could - for example - use the
exception and get your language specific exception description for it.

btw, I'm using the foreign key constraint name in the client side exception
and I'm formulating a user-understandable exception from this.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Upscene Productions