Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unique key generator
Message
De
04/01/2000 17:58:13
 
 
À
04/01/2000 17:17:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00312803
Message ID:
00312825
Vues:
31
>Hi,
>
>I'm using this function to get unique ID numbers for various files. The "SYSTEM" file contains one record with several fields of unique numbers.
>
>A typical call to the function looks like this:
>
>cOrderID = NextNumber( "NxtOrderNo", 10 )
>
>The problem is I'm getting duplicate order numbers!!!
>
>Can anyone spot the reason why this might happen?
>
>Here's the function:
>
>
>    *-------------------------------------------------
>FUNCTION NextNumber
>    * get the next incremental number for the passed field, padded with
>    * leading zeros
>
>    PARAMETER cField,nLen
>
>    cOldAlias = ALIAS()
>    lUsed = USED( "System" )
>    IF ! lUsed
>        USE SYSTEM IN 0
>    ENDIF
>    SELECT SYSTEM
>    lDone = .F.
>    DO WHILE ! lDone
>        IF FLOCK()
>            nReturnNum = &cField
>            REPLACE &cField WITH &cField + 1
>            cReturnNum = PADL( nReturnNum, nLen, '0' )
>            UNLOCK
>            lDone = .T.
>        ELSE
>            INKEY(.5)
>        ENDIF
>    ENDDO
>    IF ! EMPTY( cOldAlias )
>        SELECT (cOldAlias)
>    ENDIF
>    IF ! lUsed
>        USE IN SYSTEM
>    ENDIF
>    RETURN cReturnNum
>
>
>
>TIA

You might want to make sure there is no buffering enabled for this particular table.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform