Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Key generation
Message
De
01/07/2002 10:47:04
 
 
À
01/07/2002 10:19:25
Paul Robinshaw
Silkworm Technologies Limited
Macclesfield, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00673857
Message ID:
00673880
Vues:
16
Are you using a Novell or Windows server and which version?


>Hi All,
>
>I'm using Craig Berntson's key generation routine:
>
>
>
>LPARAMETERS tcIDType, tnNumToGet
>
>LOCAL llNotUsed, lnArea, lnRetVal
>
>llNotUsed = .F.
>llCanLock = .F.
>lnArea = SELECT()
>
>IF !USED( "idcount" )
>	USE idcount IN 0
>	llNotUsed = .T.
>ENDIF
>SELECT idcount
>SET ORDER TO TAG table
>
>*** Lock the entire table
>DO WHILE !FLOCK()
>ENDDO
>	
>SEEK UPPER( tcIDType )
>
>IF FOUND()
>	
>	*** If we find the record then return this value
>	lnRetVal = idcount.id
>	REPLACE id WITH lnRetVal + IIF( EMPTY( tnNumToGet ), 1, tnNumToGet )
>	
>ELSE
>
>	*** Record not found do create one
>	INSERT INTO idcount ( id, table, tdesc ) VALUES ( 2, tcIDType )
>	lnRetVal = 1
>
>ENDIF
>
>FLUSH
>UNLOCK
>
>IF llNotUsed
>	USE IN idCount
>ENDIF
>
>SELECT( lnArea )
>
>RETURN lnRetVal
>
>
>
>Unfortunately, I'm getting duplicates as a result. They're really wierd as they're in batches, for instance I might get keys 316202,316203,316204,316205 for records 100-103 and then 316202,316203,316204,316205 for 104-107 and then the next key generated is 316206 and everything is synchronised again. Any help is appreciated.
>
>Regards
>
>Paul
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform