国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

一個四用戶信息同步更新的存儲過程

2024-07-21 02:11:16
字體:
來源:轉載
供稿:網友

不實用,之所以寫,一為領導的要求,另外也熟悉下寫代碼,代碼多寫點也沒什么壞處,并且寫了之后發現臨時表還挺容易用的,數據量小的時候,并顯不出臨時表速度不行的問題.

代碼如下:

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][email protected]
select @intcashamount2=[amount] from [dbo].[money] where [userid][email protected]
select @intcashamount3=[amount] from [dbo].[money] where [userid][email protected]
select @intcashamount4=[amount] from [dbo].[money] where [userid][email protected]

create table #temp1(ttemp float)

if @[email protected]<0
 begin
  set @[email protected]/@intwantedamount1
  insert into #temp1 values(@ftemp)
 end


if @[email protected]<0
 begin
  set @[email protected]/@intwantedamount2
  insert into #temp1 values(@ftemp)
 end

if @[email protected]<0
 begin
  set @[email protected]/@intwantedamount3
  insert into #temp1 values(@ftemp)
 end

if @[email protected]<0
 begin
  set @[email protected]/@intwantedamount4
  insert into #temp1 values(@ftemp)
 end

set @ftemp=(select min(@ftemp) from #temp)
drop table #temp1

if @ftemp<@frate
begin
 set @[email protected]
 set @bneedrecalc=1
end

if @bneedrecalc=1
begin
 set @[email protected]*@frate
 set @[email protected]*@frate
 set @[email protected]*@frate
 set @[email protected]*@frate
end

begin tran
exec [prmoney_updatecash]
 @chvmodename,   -- 通過什么方式,如'web'、'gameserver'等
 @chvsourcename,  -- 方式的源,如'金幣麻將服務器'、'虛擬股市'等
 @chvremark,  -- 其它信息 注釋.
 @intuserid1,    -- 用戶id
 0, -- 相關的用戶id
 @intwantedamount1,   -- 希望更新的數量(>0 加金, <0 扣金)
 0,    -- 稅金(稅金>0,要在現金中扣除,游戲服務器可以置為0)
 @chvipaddress1,  -- ip地址
 0, -- 機器碼
 1    -- 是否做log,如果>0,則表示做log,否則不做log

exec [prmoney_updatecash]
 @chvmodename,   -- 通過什么方式,如'web'、'gameserver'等
 @chvsourcename,  -- 方式的源,如'金幣麻將服務器'、'虛擬股市'等
 @chvremark,  -- 其它信息 注釋.
 @intuserid2,    -- 用戶id
 0, -- 相關的用戶id
 @intwantedamount2,   -- 希望更新的數量(>0 加金, <0 扣金)
 0,    -- 稅金(稅金>0,要在現金中扣除,游戲服務器可以置為0)
 @chvipaddress2,  -- ip地址
 0, -- 機器碼
 1    -- 是否做log,如果>0,則表示做log,否則不做log

exec [prmoney_updatecash]
 @chvmodename,   -- 通過什么方式,如'web'、'gameserver'等
 @chvsourcename,  -- 方式的源,如'金幣麻將服務器'、'虛擬股市'等
 @chvremark,  -- 其它信息 注釋.
 @intuserid3,    -- 用戶id
 0, -- 相關的用戶id
 @intwantedamount3,   -- 希望更新的數量(>0 加金, <0 扣金)
 0,    -- 稅金(稅金>0,要在現金中扣除,游戲服務器可以置為0)
 @chvipaddress3,  -- ip地址
 0, -- 機器碼
 1    -- 是否做log,如果>0,則表示做log,否則不做log
exec [prmoney_updatecash]
 @chvmodename,   -- 通過什么方式,如'web'、'gameserver'等
 @chvsourcename,  -- 方式的源,如'金幣麻將服務器'、'虛擬股市'等
 @chvremark,  -- 其它信息 注釋.
 @intuserid4,    -- 用戶id
 0, -- 相關的用戶id
 @intwantedamount4,   -- 希望更新的數量(>0 加金, <0 扣金)
 0,    -- 稅金(稅金>0,要在現金中扣除,游戲服務器可以置為0)
 @chvipaddress4,  -- ip地址
 0, -- 機器碼
 1    -- 是否做log,如果>0,則表示做log,否則不做log
commit tran
return 1


go
set quoted_identifier off
go
set an

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柞水县| 上杭县| 东至县| 白水县| 合江县| 黔西县| 双鸭山市| 舞钢市| 炎陵县| 榆社县| 马龙县| 江达县| 平泉县| 巴彦淖尔市| 门源| 教育| 碌曲县| 姚安县| 南郑县| 南部县| 丰都县| 武陟县| 深水埗区| 阳江市| 凌海市| 贺州市| 嵊泗县| 石楼县| 文安县| 福鼎市| 诸城市| 岢岚县| 油尖旺区| 余庆县| 郎溪县| 霍城县| 迁西县| 石城县| 博罗县| 耿马| 会宁县|