Subject | Re: [IBO] Generator values not udpated |
---|---|
Author | Helen Borrie |
Post date | 2008-11-06T21:58:20Z |
At 06:02 AM 7/11/2008, you wrote:
a) If you have GeneratorLinks set for this table (either at dataset level or at connection level) then IBO is already calling Gen_ID() and assigning a fresh value to the **parameter** during the BeforeInsert event
b) then, meanwhile, you are invoking the Gen_ID() method separately yourself and pushing the newest value into a local variable
So you will have two possible values skimmed off the generator when you really want only one. If (a) happened first then the value will be lower; or it will be higher if (b) happened first.
At some point (not shown to us) your code has to assign the value in the local variable to the Insert parameter. So, depending on your timing, one or the other will be "the one", while the other will simply disappear.
If you don't need that value as a variable then remove your code in (b) and let GeneratorLinks do its thing.
Helen
>FB 1.5 Embedded.My guess is that you are combining IBO's built-in generator-fetching behaviour with your own, inadvertently, viz.
>
>I have some pretty easy to understand code where I get a generator
>value and insert a new record in a table--I do this for various
>tables. I am using Delphi and IBO, and here is an example:
>
> lPersonID := FIBConn.Gen_ID('GEN_PERSON_ID', 1);
>
>where lPersonID is an integer, and FIBConn is a TIBODatabase.
>
>Multiple inserts happen to each table and the ID's fr the new records
>are exactly what I would expect.
>
>But occasionally, the values for the generators are reverted back to
>their values were updated--the values in the tables are correct, it's
>just the generators that are not correct. There is no rollbacks (and
>even if there was, the generators shouldn't be rolled back, right?).
>
>It ends up causing major headaches for me.
>
>Any ideas on what might cause this?
a) If you have GeneratorLinks set for this table (either at dataset level or at connection level) then IBO is already calling Gen_ID() and assigning a fresh value to the **parameter** during the BeforeInsert event
b) then, meanwhile, you are invoking the Gen_ID() method separately yourself and pushing the newest value into a local variable
So you will have two possible values skimmed off the generator when you really want only one. If (a) happened first then the value will be lower; or it will be higher if (b) happened first.
At some point (not shown to us) your code has to assign the value in the local variable to the Insert parameter. So, depending on your timing, one or the other will be "the one", while the other will simply disappear.
If you don't need that value as a variable then remove your code in (b) and let GeneratorLinks do its thing.
Helen