Subject | Re: [firebird-support] Generating unique continual integers for invoice numbering |
---|---|
Author | Ann W. Harrison |
Post date | 2007-12-14T19:20:58Z |
toldy007@... wrote:
and potential deadlocks. The cost of that performance is
losing an occasional number. If you want an unbroken sequence,
you'll have to serialize your updates.
Create a table to hold the unique integer. In your application,
update the counter and use the new value. Until you commit,
no one else can update the counter. If the first action of the
transaction is the update of the counter, that's all you have to
rollback when you get the "update conflict" error.
Best regards,
Ann
> Thanks for your reply Marcin.Generators are outside transaction context to avoid waits
>
> I think that your solution won't solve my problem. As I know, BeforeInsert will be called when the
> INSERT is called and not after the commit!
>
> Thus if there is a problem with the INSERT or there is a rollback, a concurrent transaction
> inserting a record at the same time could cause a gap in the numbering!
>
> Any more ideas?
and potential deadlocks. The cost of that performance is
losing an occasional number. If you want an unbroken sequence,
you'll have to serialize your updates.
Create a table to hold the unique integer. In your application,
update the counter and use the new value. Until you commit,
no one else can update the counter. If the first action of the
transaction is the update of the counter, that's all you have to
rollback when you get the "update conflict" error.
Best regards,
Ann