Page 1 of 1

Getting an absolute generator value

Posted: Thu 19 Jan 2012 17:27
by kstantonnw
Greetings!

I'm having a situation when my customers need an order number which is based on a generator, sometimes the order number they get has already been used.

Is there a sure-fire way/procedure to make sure of getting an absolute unique order number? I thought generators work outside the transaction but apparently not?

I'm using, Delphi 6, IBDAC latest version and Firebird 1.56.

Thanks for any help!

Kevin

Posted: Fri 20 Jan 2012 10:10
by AndreyZ
Hello,

Generators are transaction-independent. You can find more information about it here (in the "Generators and transactions" section): http://www.firebirdsql.org/manual/gener ... asics.html . As you can see from this article, there is the possibility to obtain the same value from a generator that was already used. You can call the gen_id function with negative or zero increment that may return a value that was already used. To avoid such problems using IBDAC, you must not set the TCustomIBCDataSet.GeneratorStep property to zero or negative values (unless you are absolutely sure about what you are doing).