Subject | Generators, revisited |
---|---|
Author | Kevin Stanton |
Post date | 2004-09-10T23:15:54Z |
Greetings,
I'm getting into hot water here as invoice numbers are being duplicated.
somewhere/somehow, this is not true, or the statements below do not properly
increment the generator. I'm sure it's me somehow.
Does anyone see a flaw in the following function:
(qryGetInvNo2 is an IBO TIB_DSQL component)
function TdmInvoice.GetInvoiceNos(const InvCnt: Integer; const Inventory :
Boolean): Integer;
begin
try
trInvPost.StartTransaction;
qryGetInvNo2.SQL.Clear;
If (Pos('SENECA', Uppercase(CoName)) > 0) and (Inventory = True) then
qryGetInvNo2.SQL.Add('select gen_id (gen_invoiceno_pi, '+
IntToStr(InvCnt) + ') as NextInvNo from rdb$database')
else
qryGetInvNo2.SQL.Add('select gen_id (gen_invoiceno, '+
IntToStr(InvCnt) + ') as NextInvNo from rdb$database');
qryGetInvNo2.Active := True;
Result := qryGetInvNo2.FieldByName('NextInvNo').AsInteger;
trInvPost.Commit;
except
trInvPost.Rollback;
raise;
end;
end;
This is the first routine to run at time of posting the invoice batch.
I have 2 invoice journals from 2 different users, same day, one in the AM,
the other after 1 PM.
The journals show the same invoice number. I have never gotten a support
call on the raise portion of the above try/except. These particular users
are quite good on reporting errors.
Environment:
Firebird 1.03
Delphi 6.2
IBO Version 4.2.Gb
Thanks very much in advance to anyone that can shed some light and save my
backside.
Kevin
I'm getting into hot water here as invoice numbers are being duplicated.
>From what I know, generators work "outside" the transaction thus, they can"never be duplicated". Such is the premise I'm working on, but
somewhere/somehow, this is not true, or the statements below do not properly
increment the generator. I'm sure it's me somehow.
Does anyone see a flaw in the following function:
(qryGetInvNo2 is an IBO TIB_DSQL component)
function TdmInvoice.GetInvoiceNos(const InvCnt: Integer; const Inventory :
Boolean): Integer;
begin
try
trInvPost.StartTransaction;
qryGetInvNo2.SQL.Clear;
If (Pos('SENECA', Uppercase(CoName)) > 0) and (Inventory = True) then
qryGetInvNo2.SQL.Add('select gen_id (gen_invoiceno_pi, '+
IntToStr(InvCnt) + ') as NextInvNo from rdb$database')
else
qryGetInvNo2.SQL.Add('select gen_id (gen_invoiceno, '+
IntToStr(InvCnt) + ') as NextInvNo from rdb$database');
qryGetInvNo2.Active := True;
Result := qryGetInvNo2.FieldByName('NextInvNo').AsInteger;
trInvPost.Commit;
except
trInvPost.Rollback;
raise;
end;
end;
This is the first routine to run at time of posting the invoice batch.
I have 2 invoice journals from 2 different users, same day, one in the AM,
the other after 1 PM.
The journals show the same invoice number. I have never gotten a support
call on the raise portion of the above try/except. These particular users
are quite good on reporting errors.
Environment:
Firebird 1.03
Delphi 6.2
IBO Version 4.2.Gb
Thanks very much in advance to anyone that can shed some light and save my
backside.
Kevin