Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is the VFP File System Stable
Message
De
20/10/2001 07:10:38
Calvin Smith
Wayne Reaves Computer Systems
Macon, Georgie, États-Unis
 
 
À
19/10/2001 20:06:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00571072
Message ID:
00571284
Vues:
23
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!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform