Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find unused number in table
Message
De
07/05/2017 17:50:34
 
 
À
07/05/2017 15:48:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01650911
Message ID:
01650913
Vues:
61
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform