in sql .... wz_crate_character i have this ...
/*
1) 橇肺矫廉疙 : WZ_CreateCharacter
2) 累诀老 : 2003. 09. 15.
3) 累诀磊疙 : 眠槛
4) 傈崔牢磊 :
拌沥沥焊, 某腐磐疙, 努贰胶 鸥涝, 己傍咯何 馆券沥焊
5) 馆券牢磊(Result) :
1 : 悼老 某腐磐疙 粮犁
2 : 后浇吩捞 粮犁 窍瘤 臼澜
3 何磐 ~ : SQL Error Code
6) 努贰胶 鸥涝
0 : 孺付过荤
16 : 孺扁荤
32 : 夸沥
48 : 付八荤
64:促农肺靛
7) VERSION
1
8) Last Update Date : 2004.06.15
2003.10.16 : 飘罚黎记 困摹 坷幅 (SaemSong)
BEGIN TRAN 巩捞 甸绢啊扁 傈俊 悼老某腐疙 粮犁矫 ProcEnd 肺 GOTO 茄促
捞锭, ProcEnd俊急 费归捞唱 目乖阑 角青窍骨肺 牢秦
TranProcEnd甫 眠啊窍咯 飘罚璃记 贸府甫 窍瘤 臼绰 镑栏肺 GOTO茄促.
*/
CREATE Procedure [dbo].[WZ_CreateCharacter]
accountID varchar(10), --// 拌沥 沥焊
name varchar(10), --// 某腐磐
class tinyint --// Class Type
AS
Begin
SET NOCOUNT ON
SET XACT_ABORT ON
DECLARE
Result tinyint
--// 搬苞蔼 檬扁拳
SET
Result = 0x00
--====================================================================================
-- 某腐磐 粮犁咯何 犬牢
--====================================================================================
If EXISTS ( SELECT Name FROM Character WHERE Name =
name )
begin
SET
Result = 0x01 --// 悼老 某腐磐疙 粮犁
GOTO ProcEnd
end
BEGIN TRAN
--====================================================================================
-- 拌沥 粮犁 咯何 犬牢 棺 后 浇吩 沥焊 犬牢窍咯 历厘
--====================================================================================
If NOT EXISTS ( SELECT Id FROM AccountCharacter WHERE Id =
accountID )
begin
INSERT INTO dbo.AccountCharacter(Id, GameID1, GameID2, GameID3, GameID4, GameID5, GameIDC)
VALUES
accountID,
name, NULL, NULL, NULL, NULL, NULL)
SET
Result = @@Error
end
else
begin
--// 某腐磐 后 浇吩 汲沥
Declare @g1 varchar(10), @g2 varchar(10), @g3 varchar(10), @g4 varchar(10), @g5 varchar(10)
SELECT @g1=GameID1, @g2=GameID2, @g3=GameID3, @g4=GameID4, @g5=GameID5 FROM dbo.AccountCharacter Where Id =
accountID
if( ( @g1 Is NULL) OR (Len(@g1) = 0))
begin
UPDATE AccountCharacter SET GameID1 =
name
WHERE Id =
accountID
SET
Result = @@Error
end
else if( @g2 Is NULL OR Len(@g2) = 0)
begin
UPDATE AccountCharacter SET GameID2 =
name
WHERE Id =
accountID
SET
Result = @@Error
end
else if( @g3 Is NULL OR Len(@g3) = 0)
begin
UPDATE AccountCharacter SET GameID3 =
name
WHERE Id =
accountID
SET
Result = @@Error
end
else if( @g4 Is NULL OR Len(@g4) = 0)
begin
UPDATE AccountCharacter SET GameID4 =
name
WHERE Id =
accountID
SET
Result = @@Error
end
else if( @g5 Is NULL OR Len(@g5) = 0)
begin
UPDATE AccountCharacter SET GameID5 =
name
WHERE Id =
accountID
SET
Result = @@Error
end
else
--// 秦寸 后 浇吩 沥焊啊 粮犁 窍瘤 臼促.
begin
SET
Result = 0x03
GOTO TranProcEnd
end
end
--====================================================================================
-- 某腐磐 沥焊 历厘
--====================================================================================
if(
Result <> 0 )
begin
GOTO TranProcEnd
end
else
begin
INSERT INTO dbo.Character(AccountID, Name, cLevel, LevelUpPoint, Class, Strength, Dexterity, Vitality, Energy, Inventory,MagicList,
Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY, MDate, LDate, Quest, DbVersion, Leadership,money )
SELECT
accountID As AccountID,
name As Name, Level, 1000,
class As Class,
Strength, Dexterity, Vitality, Energy, Inventory,MagicList, Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY,
getdate() As MDate, getdate() As LDate, Quest, DbVersion, Leadership,1000000000
FROM DefaultClassType WHERE Class =
class
SET
Result = @@Error
end
TranProcEnd: -- GOTO
IF (
Result <> 0 )
ROLLBACK TRAN
ELSE
COMMIT TRAN
ProcEnd:
SET NOCOUNT OFF
SET XACT_ABORT OFF
--====================================================================================
-- 搬苞蔼 馆券 贸府
-- 0x00 : 某腐磐 粮犁, 0x01 : 己傍肯丰, 0x02 : 某腐磐 积己 角菩 , 0x03 : 后浇吩 粮犁窍瘤 臼绰促
--====================================================================================
SELECT
CASE
Result
WHEN 0x00 THEN 0x01 --// 己傍 馆券
WHEN 0x01 THEN 0x00 --// 某腐磐 粮犁
WHEN 0x03 THEN 0x03 --// 后浇吩捞 粮犁窍瘤 臼绰促.
ELSE 0x02 --// 扁鸥 俊矾内靛绰 积己 圾菩 馆券
END AS Result
End
GO