Subject | RE: [firebird-support] Get duplicate generator value? Am I doing wrong? |
---|---|
Author | Helen Borrie |
Post date | 2005-04-01T22:34:58Z |
At 07:47 AM 1/04/2005 -0800, Kevin Stanton wrote:
though. This routine could certainly return duplicates - it would only
take the increment expression evaluating to '0' to cause that.
number. Using client code to mess around with generator values needs a
very even head. Checking that the increment value is > 0 would be essential.
One line of code as compared with about 8. Code re-use is the key here.
Why keep a dog and do the barking yourself?
time. Many gazillions of generators have rolled out since then. I would bet
that something else they had to fix in the transition to v.1.5 also forced
them to fix whatever was causing that problem (revisiting their return
structure without a fresh call to gen_id() ?)
./heLen
>Hi Helen,This doesn't look like my code! maybe a mod of someone else's,
>
>I thought there was also a transaction issue as well. I was getting
>duplicates as well at one point using a TIB_Cursor and you recommended the
>following:
>
>qryGetOrderNos is TIB_DSQL
>
> with qryGetOrderNos do
> begin
> try
> trNextID.StartTransaction;
>
> SQL.Strings[0] := 'select gen_id ( gen_orderno, ' + IntToStr(OrderCnt)
>+ ' ) as EOrderNo from rdb$database';
> If NOT Prepared then Prepare;
> Execute;
> eo := FieldByName('EOrderNo').AsInteger;
> trNextID.Commit;
> except
> trNextID.Rollback;
> raise;
> end;
> end;
though. This routine could certainly return duplicates - it would only
take the increment expression evaluating to '0' to cause that.
>This has always confused me because in the docs that I've read, theIt does. But gen_id(MyGenerator, 0) is always going to return a duplicate
>generator function works independent/outside of transactions thus always
>guaranteeing a unique value.
number. Using client code to mess around with generator values needs a
very even head. Checking that the increment value is > 0 would be essential.
>(I'm using FB 1.03, soon to be 1.5.x)Not better or more bullet-proof, just more elegant and always consistent.
>
>Is using the IB_Connection a better, more bullet-proof way of retrieving
>generator values?
One line of code as compared with about 8. Code re-use is the key here.
Why keep a dog and do the barking yourself?
>Someone else posted a reply stating that once he moved toIf so, it's the first I've heard of it. v.1.0.3 has been around a long
>FB 1.5, the problem went away. Is this a possible bug w/ <= 1.3?
time. Many gazillions of generators have rolled out since then. I would bet
that something else they had to fix in the transition to v.1.5 also forced
them to fix whatever was causing that problem (revisiting their return
structure without a fresh call to gen_id() ?)
./heLen