Subject Re: [IBO] Generator not incrementing
Author Thomas Steinmaurer
>> I have the same exact thing going on. My customers
>> occasionally call and report order numbers (a generator)
>> being reissued. A couple have called in the last couple
>> of weeks - this is a pretty serious problem that I need to
>> figure out.
>
> Here is a code snippets for checking generators:
>
> procedure TdmMaster.CheckGeneratorValue(const aGenName, aTableName, aTableID: string);
> var
> lCur: TIB_Cursor;
> lGenValue: integer;
> begin
> lCur := CreateCursor(Format('Select Max(%s) from %s', [aTableID, aTableName]));

You know that doing a MAX for this scenario isn't reliable in a
multi-user environment?

--
With regards,

Thomas Steinmaurer
Upscene Productions
http://www.upscene.com
http://blog.upscene.com/thomas/

Download LogManager Series, FB TraceManager today!
Continuous Database Monitoring Solutions supporting
Firebird, InterBase, Advantage Database, MS SQL Server
and NexusDB!


> try
> lCur.First;
> lGenValue := lCur.Fields[0].AsInteger;
> finally
> lCur.Free;
> end;
>
> if FIBConn.Gen_ID(aGenName, 0)<lGenValue then
> ExecSQL('SET GENERATOR %s TO %d', [aGenName, lGenValue]);
> end;
>
> And I've started using the following where the problem has occurred:
>
> function TdmMaster.GetNewKeyID(const aTableName, aFieldName, aGenName: string): integer;
> var
> lMaxID: integer;
> begin
> lMaxID := GetMaxKeyID(aTableName, aFieldName);
> repeat
> result := dmMaster.IBConn.Gen_ID(aGenName, 1);
> until result> lMaxID;
> end;
>
> HTH,
>
> Ed Dressel
>
>
>
> ------------------------------------
>
> ___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
> ___________________________________________________________________________
> http://www.ibobjects.com - your IBO community resource for Tech Info papers,
> keyword-searchable FAQ, community code contributions and more ! Yahoo! Groups Links
>
>
>