不实用,之所以写,一为领导的要求,另外也熟悉下写代码,代码多写点也没什么坏处,并且写了之后发现临时表还挺容易用的,数据量小的时候,并显不出临时表速度不行的问题.
代码如下:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
/*
Name:游戏中四人数据同时更新
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:不用重算 ;1:需要重算
set @FRate=1.0
set @FTemp=1.0
set @bNeedReCalc=0
Declare @FTemp1 float,@FTemp2 float,@FTemp3 float,@FTemp4 float
--这里要注意,更新用户现金取数据库中的数据,跟游戏服务器能否保持一致
--取得用户现金
select @intCashAmount1=[Amount] from [dbo].[Money] where [UserID]=@intUserID1
select @intCashAmount2=[Amount] from [dbo].[Money] where [UserID]=@intUserID2
select @intCashAmount3=[Amount] from [dbo].[Money] where [UserID]=@intUserID3
select @intCashAmount4=[Amount] from [dbo].[Money] where [UserID]=@intUserID4
Create Table #Temp1(TTemp float)
if @intCashAmount1 @intWantedAmount1<0
begin
set @FTemp=-@intCashAmount1/@intWantedAmount1
insert into #temp1 values(@FTemp)
end
if @intCashAmount2 @intWantedAmount2<0
begin
set @FTemp=-@intCashAmount2/@intWantedAmount2
insert into #temp1 values(@FTemp)