The information in this article applies to:
SUMMARYThere are several ways to generate a unique string for a key field value. One method of doing this is described below. MORE INFORMATION
The following code is adapted from the "FoxPro 2.5 Advanced Developer's
Handbook" by Adams and Powell, Chapter 18, page 644.
Theoretically, this method allows more possible keys than FoxPro can store
records, without a duplicate; however, there is the possibility of
duplication because of the cyclic nature of the algorithm (which is based
on the system time and date).
The default 8-character return from UKEY() will be sufficient for most systems and the chance of a duplicate is significantly less than 1:10**18. (The actual figure is estimated here: 36**8*10**10). To ensure uniqueness, a SELECT SQL statement can be used. For example, if you were using a database alias of MYDATA, and a key field of KEYFIELD C(8), you would use the following SELECT SQL statement:
This method will slow down as the data grows, but should be sufficient for
databases with less than 16 million records. For larger databases, use a
key length greater than 8.
REFERENCES"FoxPro 2.5 Advanced Developer[ASCII 146]s Handbook," Pat Adams and Jordan Powell, Brady Publishing, New York, NY., 1993, Chapter 18, page 644 Additional query words: VFoxWin FoxMac FoxDos FoxWin 2.50 2.50a 2.50b 2.50c 2.60 unique key avoid duplicate record
Keywords : kbcode FxprgSql |
Last Reviewed: August 23, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |