[COLOR=#333333]USE [ND_GAME_0][/COLOR]GO
/****** Object: StoredProcedure [dbo].[GM_Maker] Script Date: 20/06/2014 7:31:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create PROC [dbo].[GM_Maker_ByEmperor]
/* 인자*/
@acc varchar(24), --계정 1 @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL] varchar(12), --캐릭터 이름 2
@gm smallint, @[I][B][URL="http://forum.ragezone.com/members/2000052651.html"]clan[/URL] smallint, @[I][B][URL="http://forum.ragezone.com/members/437263.html"]clas[/URL]s smallint, @[I][B][URL="http://forum.ragezone.com/members/437263.html"]clas[/URL]s_grade smallint,
@vsex smallint, --성별 3 @[I][B][URL="http://forum.ragezone.com/members/334177.html"]Cons[/URL]ttitution int, --생기 4 @[I][B][URL="http://forum.ragezone.com/members/289231.html"]Zen[/URL] int, --진기 5 @[I][B][URL="http://forum.ragezone.com/members/791041.html"]inter[/URL]lligence int, --영기 6 @[I][B][URL="http://forum.ragezone.com/members/372998.html"]dexterity[/URL] int, --심기 7
@str int, --정기 8
@vhair smallint, --머리모양 9
@vface smallint, --얼굴모양 10
@vluck smallint, -- 운 11 @[I][B][URL="http://forum.ragezone.com/members/437382.html"]Vam[/URL]or smallint, --상의 12
@vpants smallint, --하의 13 @[I][B][URL="http://forum.ragezone.com/members/773276.html"]zone[/URL] smallint,
@x real, @[I][B][URL="http://forum.ragezone.com/members/342465.html"]z[/URL] real, @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_life_pw int, -- 최대 체력 14 @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_force_pw int, -- 최대 내력 15 @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_con_pw int, -- 최대 영력 16 @[I][B][URL="http://forum.ragezone.com/members/239789.html"]Null[/URL]_space1 smallint, -- 최대 심력 17 @[I][B][URL="http://forum.ragezone.com/members/239789.html"]Null[/URL]_space2 smallint, -- 최대 정력 18 @[I][B][URL="http://forum.ragezone.com/members/501312.html"]level[/URL] smallint,
@BK bigint,
@GK int,
@acc_id int, -- 유저의 acc_uid 19
@vunique_id int OUTPUT, --유니크 아이디 20 @[I][B][URL="http://forum.ragezone.com/members/786577.html"]Result[/URL] int OUTPUT --result값 21
AS
DECLARE @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL] int, @[I][B][URL="http://forum.ragezone.com/members/1333370092.html"]already[/URL]Name int
DECLARE @[I][B][URL="http://forum.ragezone.com/members/864679.html"]table[/URL]_index INT
SET @[I][B][URL="http://forum.ragezone.com/members/1333370092.html"]already[/URL]Name = 0
/* 캐릭터 이름 @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL] 을 조건으로 동명의 다른 컬럼이 존재하는지
검사한다.(캐릭터 이름의 고유이성을 지켜주기 위해)*/
SELECT @[I][B][URL="http://forum.ragezone.com/members/1333370092.html"]already[/URL]Name = 1 FROM ND_V01_Charac WHERE chr_name = @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL] --@@rowcount에 결과컬럼 저장
/* 같은 캐릭터 이름을 같은 컬럼이 이미 존재한다면
작업을 포기하고 @[I][B][URL="http://forum.ragezone.com/members/786577.html"]Result[/URL] = 1을 OUTPUT하고 종료한다.*/
if @[I][B][URL="http://forum.ragezone.com/members/1333370092.html"]already[/URL]Name > 0
BEGIN
SET @[I][B][URL="http://forum.ragezone.com/members/786577.html"]Result[/URL] = 1
RETURN
END
SET @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL] = 0
SELECT @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL] = count(*) FROM ND_V01_Charac WHERE acc_id = @acc_id AND delete_flag = 0 - @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL] ( 계정이 갖고있는 캐릭터수)
if @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL] > 2
BEGIN
SET @[I][B][URL="http://forum.ragezone.com/members/786577.html"]Result[/URL] = 2
RETURN
END
SET @[I][B][URL="http://forum.ragezone.com/members/786577.html"]Result[/URL] = 1
--BEGIN TRAN --트랜잭션 처리 시작
INSERT ND_V01_Charac
([user_id],
[chr_name],
[gm],
[party],
[class],
[class_grade],
[sex],
[hair],
[face],
[luck] ,
[acc_id])
VALUES
(@acc,
@[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL],
@gm,
@[I][B][URL="http://forum.ragezone.com/members/2000052651.html"]clan[/URL],
@[I][B][URL="http://forum.ragezone.com/members/437263.html"]clas[/URL]s,
@[I][B][URL="http://forum.ragezone.com/members/437263.html"]clas[/URL]s_grade,
@vsex,
@vhair,
@vface,
@vluck,
@acc_id)
/* 캐릭터 이름 @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL]을 조건으로 SELECT 쿼리를 실행하여
해당 캐릭터의 유티크아이디를 OUTPUT 인수 @vUid 로 얻어진다.*/
SELECT @vunique_id=unique_id FROM ND_V01_Charac WHERE [chr_name] = @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL]
/* 위 셀렉트 문으로 얻어진 @vUid(유니크아이디값)를 이용해 4개 테이블을 동시 생성 */
-- 인벤토리 버전 2 에서 추가된 사항.
EXEC DSSP_InvenV2_FindTableIndex @vunique_id, @[I][B][URL="http://forum.ragezone.com/members/864679.html"]table[/URL]_index OUTPUT
INSERT ND_V01_Charac_Level
(unique_id, max_life_pw, max_force_pw, max_con_pw, constitution, zen, intelligence, dexterity, [str])
VALUES
(@vunique_id, @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_life_pw, @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_force_pw, @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_con_pw, @[I][B][URL="http://forum.ragezone.com/members/334177.html"]Cons[/URL]ttitution, @[I][B][URL="http://forum.ragezone.com/members/289231.html"]Zen[/URL], @[I][B][URL="http://forum.ragezone.com/members/791041.html"]inter[/URL]lligence, @[I][B][URL="http://forum.ragezone.com/members/372998.html"]dexterity[/URL], @str)
INSERT ND_V01_CharacState
(unique_id, inner_level, gong, honor)
VALUES
(@vunique_id, @[I][B][URL="http://forum.ragezone.com/members/501312.html"]level[/URL], @BK, @GK)
INSERT ND_V01_CurBasicInfo
(unique_id, zone, x, z, vital_power, inner_power, soul_power, heart_power, stamina_power)
VALUES ( @vunique_id, @[I][B][URL="http://forum.ragezone.com/members/773276.html"]zone[/URL], @x, @[I][B][URL="http://forum.ragezone.com/members/342465.html"]z[/URL], @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_life_pw, @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_force_pw, @[I][B][URL="http://forum.ragezone.com/members/447213.html"]Max[/URL]_con_pw, @[I][B][URL="http://forum.ragezone.com/members/239789.html"]Null[/URL]_space1, @[I][B][URL="http://forum.ragezone.com/members/239789.html"]Null[/URL]_space2)
INSERT ND_V01_Charac_Martial
(unique_id) VALUES ( @vunique_id)
INSERT ND_V01_Charac_Quest_Data
(unique_id) VALUES (@vunique_id)
INSERT ND_V01_FriendList
(unique_id) VALUES (@vunique_id)
INSERT ND_V01_Charac_MailList
(unique_id) VALUES(@vunique_id)
INSERT ND_V01_Charac_Nic
(unique_id) VALUES(@vunique_id)
INSERT ND_V01_Charac_Match
(unique_id) VALUES (@vunique_id)
INSERT ND_V01_Charac_Effect
(unique_id) VALUES (@vunique_id)
/*
INSERT ND_V03_Dismantle_Bag ( cuid, slot ) VALUES ( @vunique_id, 0 )
INSERT ND_V03_Dismantle_Bag ( cuid, slot ) VALUES ( @vunique_id, 1 )
INSERT ND_V03_Dismantle_Bag ( cuid, slot ) VALUES ( @vunique_id, 2 )
INSERT ND_V03_Dismantle_Bag ( cuid, slot ) VALUES ( @vunique_id, 3 )
INSERT ND_V03_Dismantle_Bag ( cuid, slot ) VALUES ( @vunique_id, 4 )
*/
--COMMIT TRAN [/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B][I][B]SET @[I][B][URL="http://forum.ragezone.com/members/786577.html"]Result[/URL] = 0[/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I][/B][/I]