Subject Re: [ib-support] SQL-SELECT/DELETE unique value from table in multiuser app
Author Vince Duggan
A few points to this reply:

> Hello everyone. I am writing an application using Firebird and Delphi
> 6 using the EasySoft ODBC driver.

Ant particular reason you're using ODBC. Why not IBX or IBO native

> How do I guarantee that an ACCOUNT_NUMBER does not get used more than
> once if two or more users are inserting at the same time? I think I
> want to lock the DOWNTIME_ACCOUNTS table, get the first record, delete
> the record, then unlock the table. Am I thinking correctly? :) If so,
> how is this implemented via Delphi & ODBC?

You don't need to lock the table.

Select the new value.
Delete the row, and make sure that rowcount is one.
If you successfully deleted and committed, then use the value. If you get an
error then start a new transaction and select a new value.