>table contains barcodes like
>
>create table barcode ( barcode n(7) )
>
>There are unused numbers in barcode column.
>How to find some free not used number in this table ?
>
>code
>
>
>function GetAvailableBarcode
>select max(barcode) as maxc from barcode into cursor maxc
>for i=1 to maxc-1
> sele barcode
> loca for barcode=i
> if !found()
> MessageBox('Free code'+ tran(i) )
> return i
> endif
> endfor
>messagebox('No free barcode')
>return maxc+1
>endfunc
>
>
>probably works but is probably slow since table contains thousands of codes.
>How to make this code faster ?
>Can some sql satement of index used ?
From our friends at StackOverflow:
http://stackoverflow.com/questions/1312101/how-do-i-find-a-gap-in-running-counter-with-sql