Subject | Re: [firebird-support] Incremental key |
---|---|
Author | Ann W. Harrison |
Post date | 2004-07-06T18:12:09Z |
At 01:15 PM 7/6/2004, Bjoern Reimer wrote:
records. Generators are the best answer, but they don't work well if
the user modifies the key value, and if the user takes a number then
decides not to use it, the number is gone. There are ways around that,
but they're error prone and limit concurrent inserts.
Regards,
Ann
> First: Don't use this number as primary key of your table.Good idea.
> To access your data rows use a semantic insignificant primary key.
> I'd suggest:That won't work correctly if there are concurrent transactions inserting
> * Use a SELECT MAX (Number)+1 FROM TABLE to get the number
> * end your transaction
> * Use an before insert trigger to check if someone else has selected
> this number and do another select max if so and commit your
> transaction.
records. Generators are the best answer, but they don't work well if
the user modifies the key value, and if the user takes a number then
decides not to use it, the number is gone. There are ways around that,
but they're error prone and limit concurrent inserts.
Regards,
Ann