Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Vfp50 - Auto Numbering when adding new records
Message
De
10/03/1997 10:17:39
 
 
À
10/03/1997 10:07:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00023577
Message ID:
00023580
Vues:
23
>When adding a new record (append blank), how
>can you have this new record get an "autonumber" from
>vfp50? This is not the same as "record number". A "autonumber" would be used like an ID number. It can not change while a record's "record number" can change when you PACK the records.


Write it yourself...

Use the DEFAULT VALUE in the database container to call a function that works out the next new value.

Something like:

FUNCTION NewID("tcTable")

*
* Modified By Changes
* 19/06/1996 PAM Fixed up assumption of EXCL OFF
* Fixed UNLOCK code
* 08/06/1996 PAM When running outside application, this procedure fails
* to open the system table, yet the procedure is running
* so the DBC must be available.
*----------------------------------------------------------------------

LOCAL lnNextVal
lnNextVal = 9999999

tcTable = UPPER(ALLTRIM(tcTable))

IF ! USED("system")
USE system IN 0 SHARED
*
* SHARED added to force non-exclusive open of table if
* SET EXCLUSIVE is on for any reason.
*--- PAM 19/6/1996
ENDIF

IF SEEK(tcTable,"system","syskey")
= LOCK("system")
lnNextVal = system.isysLastVal + 1
REPLACE isysLastVal WITH lnNextVal IN system
UNLOCK IN system
*
* IN setup added to release locks in the right table, found
* this failed in MU situation without it.
*--- PAM 19/6/1996
ENDIF

RETURN lnNextVal
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform