Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is the VFP File System Stable
Message
From
20/10/2001 07:10:38
Calvin Smith
Wayne Reaves Computer Systems
Macon, Georgia, United States
 
 
To
19/10/2001 20:06:09
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00571072
Message ID:
00571284
Views:
25
Craig,
Duh! Oh, PK means primary key. In my defense, I have a severe head cold. Here goes. Primary key code is as follows:

In calling program:
NewKey=GetNewPrimary()
replace theprimarykey with NewKey in thisTable

**********************
Procedure GetNewPrimary
local newTnumber,nowdbf
nowdbf=alias()
newTnumber=0
use misc in 0 again alias ms
use theTable again in 0 alias NewKeyTable order primarykey
sele ms
set reprocess to -1
set deleted off
local ix
newTnumber=ms.mytrans
sele NewKeyTable
for ix=1 to 100000
seek newTnumber
if found()
newTNumber=newTnumber+1
else
exit
endif
next
sele ms
if flock()
repl ms.mytrans with newTnumber+1
unlock in ms
endif
set deleted on
use in ms
use in NewKeyTable
if !empty(nowdbf)
sele (nowdbf)
endif
return newTnumber

While this may not be the most elegant code in the world, I do know that if it fails I will get a primary key violation in short order. I know this because originally I did not have the Set Deleted Off statement and my users generated primary key violations all over the place.

Incidently, how does one format text in this editor?
A problem is a problem only as long as it has a possible solution. Lacking that, it becomes a FACT!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform