Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GUID as PK
Message
From
06/11/2003 08:14:37
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
06/11/2003 07:40:44
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Title:
Miscellaneous
Thread ID:
00847008
Message ID:
00847019
Views:
21
>Hi,
>what should I do if I wan to use GUID as PK?
>Thank you
TEXT to m.lcProcs noshow
  Procedure GetGUID16
  Local pguid
  Declare Integer UuidCreate In 'RPCRT4.dll' String @pguid
  pguid=Replicate(Chr(0),16)
  UuidCreate(@pguid)
  Return pGUID
EndProc

  Procedure GUID16ToStr
  lparameters tcGUID16
  Local rguid
  Declare Integer StringFromGUID2 In 'Ole32.dll' ;
    string rguid, String @lpsz, Integer cchMax
  rguid=Replicate(Chr(0),80)
  StringFromGUID2(tcGUID16,@rguid,40)
  Return Strconv(Left(rGUID,76),6)
endproc
ENDTEXT

Create Database GUIDTest
lcTemp = Sys(2015)+'.prg'
Strtofile(m.lcProcs,m.lcTemp)
Append Procedures From (m.lcTemp)
Erase (m.lcTemp)

Create Table GUIDTable1 ;
  (PKID c(16) Default GetGUID16(), ;
  otherfield i )
Alter Table GUIDTable1 add primary key PKID tag PKID

Close All
For ix=1 To 10
  Insert Into GUIDTable1 (otherfield) Values (ix)
Endfor
Locate
Browse Fields PKID, otherfield, PKDecoded = GUID16ToStr(PKID)

*Close All
*Erase GUIDTest.dbc
*Erase GUIDTest.dc*
*Erase GUIDTable1.*
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform