This article introduced a four user synchronization update stored procedure instance, through this example study, you may discover that the temporary table under certain condition also can be nimble and easy to use, when the data quantity is small, it does not show the temporary table speed not to be able the question.
SET QUOTED_IDENTIFIER ON
Go
SET ANSI_NULLS on
Go
/*
Name: Four-person data in the game is updated simultaneously
Designed BY:WHBO
Designed at:2005-10-12
Modified by:
Modified at:
Memo:
*/
ALTER PROC [PRMONEY_UPDATECASH2]
@chvModeName varchar (16),
@chvSourceName varchar (64),
@chvRemark varchar (128),
@intUserID1 int,
@intUserID2 int,
@intUserID3 int,
@intUserID4 int,
@intWantedAmount1 int,
@intWantedAmount2 int,
@intWantedAmount3 int,
@intWantedAmount4 int,
@chvIPAddress1 varchar (15),
@chvIPAddress2 varchar (15),
@chvIPAddress3 varchar (15),
@chvIPAddress4 varchar (15),
@inyLog tinyint
As
SET NOCOUNT ON
Set XACT_ABORT on
Declare @intCashAmount1 int, @intCashAmount2 int, @intCashAmount3 int, @intCashAmount4 int
Declare @FRate float, @FTemp float
Declare @bNeedReCalc bit--0: Do not have to be counted; 1: Need to be counted again
Set @FRate =1.0
Set @FTemp =1.0
Set @bNeedReCalc =0
Declare @FTemp1 float, @FTemp2 float, @FTemp3 float, @FTemp4 float