Subject | Re: Generating unique continual integers for invoice numbering |
---|---|
Author | tomkrej |
Post date | 2007-12-14T12:41:01Z |
> 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!concurrent transaction
>
> Thus if there is a problem with the INSERT or there is a rollback, a
> inserting a record at the same time could cause a gap in the numbering!Yes it's true, but You have to keep on mind, that all transactions see
>
only commited data, so, if You have a unique key on that column (plus
on column with year), than You have to gain continual integers.
Scenario:
Rollback - nothing is happen, You did not update any record
Commit - OK, it is written
Two transactions commiting at the same time:
1.trans - OK, 2.trans - Exception - UNIQUE CONSTRAINT - You have to
ask for new integer
When both are rollback, or only one is commited everything is OK.
Tom