Subject Re: Get duplicate generator value? Am I doing wrong?
Author bigredinf
> Given that your calculation causes the generated number, at its current
> order, to shed the first digit, you would start getting duplicates
if you
> spun more than 9999 numbers of this generator in a single month.

I understand,But I can sure my client won't key over 2000 records
within 1 month. so I used this structure lotno.

If you
> lost generator numbers for some reason during that month, the maximum
> number of potential lot numbers might be considerably less than the
> supposed 9999.


> I don't see where "2 hours" fits in. You will begin producing
duplicates
> if you use up more than 9999 generated numbers in one calendar month.

I check the data on firebird, the later one record with same
lotno value was inserted after first one by 120 minuts,
and there is not other record inserted into the table within
that period.
So I donot think there will happen
10000 genertor call and not insert one record into table
in thar "120 minutes" period.


>
> 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;
>
> But I think you need to add two characters to the length of LotNo and
> include the day part of the date in your string.

If my client have such loading
(over 1000 records per day) ,I will take this advice.


Thank you for your quick reply.

Kadee/Bigredinf