Subject Re: [firebird-support] SELECT MAX() or Generator
Author Fabricio Araujo
Your approach is suicidal in a multi-user environment.
DO NOT USE THIS. You are warned. Headaches guaranteed.

Re-read the documentation (IB6 docs, FB release notes, etc),
research bibliography (The Firebird Book is a excelent source
of information) and google around the web about it.


On Thu, 15 Dec 2005 14:26:10 -0500, 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?
>
>--
>Sincerely,
>William L. Thomson Jr.
>Obsidian-Studios, Inc.
>http://www.obsidian-studios.com
>
>
>
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Visit http://firebird.sourceforge.net and click the Resources item
>on the main (top) menu. Try Knowledgebase and FAQ links !
>
>Also search the knowledgebases at http://www.ibphoenix.com
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>---
>avast! Antivirus: Inbound message clean.
>Virus Database (VPS): 0550-4, 16/12/2005
>Tested on: 16/12/2005 22:54:20
>avast! - copyright (c) 1988-2005 ALWIL Software.
>http://www.avast.com
>
>
>