Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sorting strings with integers..
Message
De
13/01/2007 17:16:48
 
 
À
13/01/2007 05:39:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6
Divers
Thread ID:
01184851
Message ID:
01185395
Vues:
20
>>There's also a bigger flaw in the PADL ideas - fields such as 'HMD1' and 'HMD01' will be identical.....

I disagree that there is a "flaw" -- if the flaw "exists" it is because you as the programmer allow the above to occur (and it is the same whether you use the PADL or TRANSFORM function). You as the programmer have to determine the next increment to set -- set the table in order, goto bottom and get last number number used and then increment it for the next value:
SET ORDER TO TAG mykey
GOTO BOTTOM
lnNextValue = INT(VAL(SUBSTR(mykey,4))) + 1
...
...
INSERT INTO mytable (mykey,...) VALUES ('HMD'+PADL(lnNextValue,5,'0'),...)
SET ORDER TO
...
You also have to be aware that using just numeric digits as above limits you in the number of records. If the mykey field is a Char(8) as above, then the numeric part is 5 digits or a limit of 99,999 records. Not a good design. You can either use a integer field type and a 'prefix' field of C(3), or if you want a single character field, then use an increment of 0-Z (that is 0,1,2,3,4,5,6,7,8,9,A,B,C,...X,Y,Z -- base 36 instead of base 10) which gives 36**5 records allowed (60,466,176)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform