Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incrementing a counter and getting its value
Message
From
05/04/2002 13:16:59
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
Incrementing a counter and getting its value
Miscellaneous
Thread ID:
00641537
Message ID:
00641537
Views:
50
Hi,

I have a table containing a counter that must be incremented each time some functions are performed. The sequence is to increment the counter and then use the new (incremented) value in subsequent operations. The question here is how to make it in such a way that I can guarantee that I'll be using the counter value I just incremented, and not by some other instance of the program being run by some other user? In standard VFP DML code I see no problem, just lock the record, increment the value and replace it, then unlock the record. But how about using SPT?

Please assume the following code fragments:
 Create Table (Pecas_Parm) (PD_ExpLiPC N (3) )

 Use  (Pecas_Parm)   In 0   Alias Pecas_Parm
Using standard VFP DML code:
 Select Pecas_Parm
 Go     Top

 rLock ()

 nPD_ExpLiPC = PD_ExpLiPC + 1

 Replace PD_ExpLiPC  with  nPD_ExpLiPC

 UnLock
How it would be using SQL Pass Through?
 cSQLString = "Update Pecas_Parm Set PD_ExpLiPC = PD_ExpLiPC + 1"

 SqlExec (nHandle, cSQLString)

 nPD_ExpLiPC = ?????
Thanks in advance,

Fernando
Next
Reply
Map
View

Click here to load this message in the networking platform