Getting an absolute generator value

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kstantonnw
Posts: 13
Joined: Mon 25 Feb 2008 17:22
Location: Oregon

Getting an absolute generator value

Post by kstantonnw » Thu 19 Jan 2012 17:27

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

AndreyZ

Post by AndreyZ » Fri 20 Jan 2012 10:10

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).

Post Reply