Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incrementing a counter and getting its value
Message
From
05/04/2002 15:38:53
 
 
To
05/04/2002 14:13:40
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00641537
Message ID:
00641610
Views:
20
This message has been marked as a message which has helped to the initial question of the thread.
Technically - if:

1) there's a BEGIN TRANSACTION to match that COMMIT TRANSACTION or you're using the Manual Transaction setting from VFP.

2) you don't mind SQL Server making two passes through the table.

IMO, I see no reason to make SQL Server do the extra work when there's a facility for just this purpose. Also, my perferred approach would be for you to call a stored procedure that would do the work and return the new value as an output parameter.
CREATE PROCEDURE incCounter
 @newValue int OUTPUT
AS
 Update Pecas_Parm Set @newValue = PD_ExpLiPC = PD_ExpLiPC + 1
 IF @@ERROR != 0 SET @newValue = NULL
-Mike

>Looking at your code I wonder: could it be implementented like this, too?
>
> cSQLString = "Update Pecas_Parm Set PD_ExpLiPC = PD_ExpLiPC + 1; Select PD_ExpLiPC From Pecas_Parm; Commit"
>
> SqlExec (nHandle, cSQLString, CurResult)
>
> nPD_ExpLiPC = CurResult.PD_ExpLiPC
>
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform