Subject Re: [firebird-support] Bad design causing problems
Author Rik Barker
Hi Woody,

Thanks for replying.

> You may be able to fashion a critical section procedure in Delphi that
>your threads share where they make the call to the procedure. This will make
>sure that only one thread accesses the procedure at a time which would

Yep, critical sections are something I'm considering, but I'd hoped to
avoid because of the bottleneck it will create on inserts. The example
I've shown is one of 4 inserts done (all with preceding selects). 10
threads all inserting at once is really pretty nippy. I'd hoped I could
use the database to handle the de-duping so the app could run faster, but I
think my threads are so isolated (as they should be) that I'm suffering the
consequences.

> However, that being said, I'm sure you will be berated (or at least
>roundly lectured) on the dangers and pitfalls of using a select procedure
>which modified the data. This is just not something you should do for
>various reasons, not the least of which is introducing a "side-affect" in an
>otherwise ordinary select routine.

When I first wrote it as a stored procedure I thought it was quite a clever
approach. I was evaluating 3 different database engines, and learning SQL
at the same time. I wanted my code to require as little change as possible
so it seemed sensible to put the database specifics in the database. From
the disapproving looks and light chastisement I've been getting, I think I
have some more reading to do. *8)

Cheers,
Rik