Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a code sequence
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01046401
Message ID:
01046413
Vues:
16
This message has been marked as a message which has helped to the initial question of the thread.
>
>  select mytable
>     go bottom
>        cod = mytable.cod + 1
>    appe blank
>        replace mytable.cod with cod
>
>
> I think this rotine is not suitable because some costumers complain
> that for some reason the code become repetead
> Is there a more eficient way to do it ?


this should be a unique-ID, correct. If so, I would employ a second table that holds
the next (or current) Id and counts them up.

I have a table (CONTROL) that has a Key-Field (the Alias or another unique Key) as well as a field for the current Value (your COD).

In my DBC I have a Method NewID() that receives the Alias (i.e. the key) and returns the next ID.

My method is quite complicated and has several options that belong to my applications, but what it merely does is open the CONTROL table (if not), locate the record for the key.

If it cannot find it, initializes it with a starting value otherwise it trys to lock the record (if rlock(....)
sets the value up by one, relieves the lock (unlock) and returns the new value as ID.

Another option would be an Autoincrement-Field if You work with VFP 9
Regards from Berlin

Frank

Dietrich Datentechnik (Berlin)
Softwarekombinat Teltow (Teltow)

Frank.Dietrich@dd-tech.de
DFPUG # 327
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform