Subject | Re: [firebird-support] SELECT MAX() or Generator |
---|---|
Author | Jason Dodson |
Post date | 2005-12-15T20:25:50Z |
I think you COMPLETELY missed the whole point of a generator.
Jason
William L. Thomson Jr. wrote:
The information transmitted herewith is sensitive information intended only for use to the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon, this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
Jason
William L. Thomson Jr. wrote:
> Some time back, I stopped using Generators. I had to many issues with--
> bad code or commits, incrementing, and not decrementing the generator.
> At times I would get gaps in numbers and etc. Overall working with them
> became a pain. I came up with a similiar way using a simple trigger, and
> was just curious to others thoughts on it.
>
> DECLARE VARIABLE max_num INTEGER;
> BEGIN
> IF(new.NUM is NULL)
> THEN
> BEGIN
> SELECT MAX(NUM) FROM MY_TABLE INTO max_num;
> new.NUM = max_num+1;
> END
> END
>
> I have been doing this for quite some time. Can't tell much if any
> difference on performance. If I delete a bunch of records in order, like
> the last 5 or 10. I do not have to worry about resetting, syncing,
> updating the generator. Or decrementing the generator at all.
>
> Anyway thought I would toss it out there. I would assume others to
> already be doing something similar?
>
The information transmitted herewith is sensitive information intended only for use to the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon, this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.