Subject | Re: [firebird-support] SELECT MAX |
---|---|
Author | Doug Chamberlin |
Post date | 2008-03-19T18:47:59Z |
Bud Millwood wrote:
updates a field in another table that is defined to be the max value.
That way you only have to query the other table's one record to get the
current max value.
I hope you are aware of the many ways that maintaining a max value this
way can go wrong and have planned on handling them. For example, in the
time it takes to obtain the current max value, increment it, and post a
new record with the calculated value, another user could have completed
the same sequence and therefore produced a collision of values.
>> Why do you want to get the max number?Another way to handle this is to place triggers on the table which
>
> It's a generated id. When the app starts we want the largest one, and we keep
> incrementing for new records.
updates a field in another table that is defined to be the max value.
That way you only have to query the other table's one record to get the
current max value.
I hope you are aware of the many ways that maintaining a max value this
way can go wrong and have planned on handling them. For example, in the
time it takes to obtain the current max value, increment it, and post a
new record with the calculated value, another user could have completed
the same sequence and therefore produced a collision of values.