Subject | RE: [firebird-support] Get duplicate generator value? Am I doing wrong? |
---|---|
Author | Kevin Stanton |
Post date | 2005-04-01T15:47:13Z |
Hi Helen,
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;
This has always confused me because in the docs that I've read, the
generator function works independent/outside of transactions thus always
guaranteeing a unique value.
(I'm using FB 1.03, soon to be 1.5.x)
Is using the IB_Connection a better, more bullet-proof way of retrieving
generator values? Someone else posted a reply stating that once he moved to
FB 1.5, the problem went away. Is this a possible bug w/ <= 1.3?
As always, thanks for the help.
Kevin
_____
From: Helen Borrie [mailto:helebor@...]
Sent: Friday, April 01, 2005 5:25 AM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Get duplicate generator value? Am I doing
wrong?
At 08:31 AM 1/04/2005 +0000, you wrote:
Since you are using IBO, you have no need for your complicated method of
getting the generator value: use the Gen_ID() function:
function afgetNewNo_str(pddate: tdate):
string;
begin
Result := IntToStr(IB_Connection1.Gen_ID(gn_lotno,1)); // returns '25418'
Result := FormatDateTime('yymm', PDDATE)
+ copy(Result, (Length(Result) - 3), 4);
// produces '05035418'
end;
_____
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/
* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.
[Non-text portions of this message have been removed]
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;
This has always confused me because in the docs that I've read, the
generator function works independent/outside of transactions thus always
guaranteeing a unique value.
(I'm using FB 1.03, soon to be 1.5.x)
Is using the IB_Connection a better, more bullet-proof way of retrieving
generator values? Someone else posted a reply stating that once he moved to
FB 1.5, the problem went away. Is this a possible bug w/ <= 1.3?
As always, thanks for the help.
Kevin
_____
From: Helen Borrie [mailto:helebor@...]
Sent: Friday, April 01, 2005 5:25 AM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Get duplicate generator value? Am I doing
wrong?
At 08:31 AM 1/04/2005 +0000, you wrote:
Since you are using IBO, you have no need for your complicated method of
getting the generator value: use the Gen_ID() function:
function afgetNewNo_str(pddate: tdate):
string;
begin
Result := IntToStr(IB_Connection1.Gen_ID(gn_lotno,1)); // returns '25418'
Result := FormatDateTime('yymm', PDDATE)
+ copy(Result, (Length(Result) - 3), 4);
// produces '05035418'
end;
_____
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/
* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.
[Non-text portions of this message have been removed]