Subject RE: [firebird-support] Generators, revisited
Author Alan McDonald
> 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

by the way, your commit or rollback on this code is quite meaningless. You
have not made any data changes in this transaction so commit is fine by
itself but there is no need to do this in it's own transaction context. You
can do this stuff in the default transaction and let it commit or rollback
according to it's needs.

Alan