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