Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uniqueness of Indexes - how do you handle this?
Message
From
14/06/2000 06:50:55
 
 
To
14/06/2000 01:08:11
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00376137
Message ID:
00380129
Views:
57
As a character field. I think I got this code from Rick Strahl's website a few years ago....
*** Run this once at the beginning of your app (in your MAIN.PRG) to declare the calls.

DECLARE INTEGER CoCreateGuid ;
  IN Ole32.dll ;
  STRING @lcGUIDStruc
DECLARE INTEGER StringFromGUID2 ;
  IN Ole32.dll ;
  STRING cGUIDStruc, ;
  STRING @cGUID, ;
  LONG nSize

*** Run this as required to get a unique key.

PROCEDURE GetGUID
cStrucGUID=SPACE(16)
cGUID=SPACE(80)
nSize=40
IF CoCreateGuid(@cStrucGUID) # 0
   RETURN ""
ENDIF
IF StringFromGUID2(cStrucGUID,@cGuid,nSize) = 0
  RETURN ""
ENDIF
RETURN STRCONV(LEFT(cGUID,76),6)
ENDPROC
>>I have to go back to an earlier point in another (or the same?) thread:
>
>>Surrogate keys are the absolute best way to guarantee a unique primary key bar none. Period. And, IMHO, the CoCreateGUID API call absolutely guarantees uniqueness spanning not only the table, but the database, the machine, the network, the freaking world.
>
>On second thought. You raise an interesting point up here. Unlike many others you do not choose for a separate PK table up here. If I may ask, what are your motivations. How do you store it in the table (data type) ?
>
>Walter,
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform