Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a code sequence
Message
De
03/09/2005 00:40:58
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01046401
Message ID:
01046511
Vues:
17
>
>  select mytable
>     go bottom
>        cod = mytable.cod + 1
>    appe blank
>        replace mytable.cod with cod
>
One more reason why you should never trust the last record has the last key: it may not really be the last record. The last record may be deleted, or the table may be filtered, or may have a filtered or Unique index active. Go Bottom will get you to the last visible record, which is not necessarily the record containing the last used key. In the case where last record was deleted, it may be undeleted later, and you end up with a duplicate.

Another possibility - we had, once upon a time, offered a customer code by simply finding the last one, taking val() of it, adding 1 to the value, and formatting it into a 000n format (four digits, zero padded). The trouble started when someone entered "xxxx" for user code. Val("xxxx")=0, so we got user 0001 - which existed already. Then we allowed digits only - and the users entered "9999" for some special code of theirs. Val("9999")+1=10000, transform(10000,"@L 9999")="****"... etc etc. All wrong. This taught me to give users searchable lists, autofill boxes, anything, just not to have them enter any codes.

But I digress... discard the previous paragraph as obsolete.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform