Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Character Database Bug Fix (SQL Script)

Junior Spellweaver
Joined
Jul 11, 2006
Messages
188
Reaction score
184
teroare asked me to make this script, for fix bug when trying to create character into a wrong filled account character row

Code:
-- Script by WoLf (02/02/2008)
-- Keep credits if you will repost this

DECLARE @account NVARCHAR(10)
DECLARE @char1 NVARCHAR(10)
DECLARE @char2 NVARCHAR(10)
DECLARE @char3 NVARCHAR(10)
DECLARE @char4 NVARCHAR(10)
DECLARE @char5 NVARCHAR(10)

DECLARE @fixed INT
SET @fixed = 0

DECLARE fixcr CURSOR FOR 
SELECT Id, ISNULL(GameID1, ''), ISNULL(GameID2, ''), ISNULL(GameID3, ''), ISNULL(GameID4, ''), ISNULL(GameID5, '') FROM AccountCharacter

OPEN fixcr

	FETCH NEXT FROM fixcr INTO @account, @char1, @char2, @char3, @char4, @char5

	WHILE @@FETCH_STATUS = 0
	BEGIN

		IF(@char1 <> '')
		BEGIN
			IF(NOT EXISTS(SELECT * FROM Character WHERE AccountID = @account AND Name = @char1))
			BEGIN
				UPDATE AccountCharacter SET GameID1 = NULL WHERE Id = @account
				SET @fixed = @fixed + 1
			END
		END
		IF(@char2 <> '')
		BEGIN
			IF(NOT EXISTS(SELECT * FROM Character WHERE AccountID = @account AND Name = @char2))
			BEGIN
				UPDATE AccountCharacter SET GameID2 = NULL WHERE Id = @account
				SET @fixed = @fixed + 1
			END
		END
		IF(@char3 <> '')
		BEGIN
			IF(NOT EXISTS(SELECT * FROM Character WHERE AccountID = @account AND Name = @char3))
			BEGIN
				UPDATE AccountCharacter SET GameID3 = NULL WHERE Id = @account
				SET @fixed = @fixed + 1
			END
		END
		IF(@char4 <> '')
		BEGIN
			IF(NOT EXISTS(SELECT * FROM Character WHERE AccountID = @account AND Name = @char4))
			BEGIN
				UPDATE AccountCharacter SET GameID4 = NULL WHERE Id = @account
				SET @fixed = @fixed + 1
			END
		END
		IF(@char5 <> '')
		BEGIN
			IF(NOT EXISTS(SELECT * FROM Character WHERE AccountID = @account AND Name = @char5))
			BEGIN
				UPDATE AccountCharacter SET GameID5 = NULL WHERE Id = @account
				SET @fixed = @fixed + 1
			END
		END

		FETCH NEXT FROM fixcr INTO @account, @char1, @char2, @char3, @char4, @char5

	END

CLOSE fixcr
DEALLOCATE fixcr

Credits: WoLf (me)
 
Junior Spellweaver
Joined
Jan 30, 2007
Messages
178
Reaction score
2
Re: [Release] Character Dabase Bug Fix (SQL Script)

Thanks m8 , ill be forever thankful for this !!
 
Newbie Spellweaver
Joined
Jan 9, 2008
Messages
34
Reaction score
4
Re: [Release] Character Dabase Bug Fix (SQL Script)

What is this for? i don't understend
 
[Czt] Coder Team Member
Joined
Aug 28, 2005
Messages
370
Reaction score
8
Re: [Release] Character Dabase Bug Fix (SQL Script)

nice release, will help lots & lots of noobies :p
 
Junior Spellweaver
Joined
Jul 11, 2006
Messages
188
Reaction score
184
Re: [Release] Character Database Bug Fix (SQL Script)

when you can't create characters, in a "empty" account, this solves the problem if the cause was wrong filled rows in AccountCharacter table
 
Newbie Spellweaver
Joined
Jan 21, 2006
Messages
56
Reaction score
0
Re: [Release] Character Database Bug Fix (SQL Script)

senks wolfulus for the release
 
Newbie Spellweaver
Joined
Jan 9, 2008
Messages
34
Reaction score
4
Re: [Release] Character Database Bug Fix (SQL Script)

Thx, nice
 
Junior Spellweaver
Joined
May 7, 2005
Messages
106
Reaction score
5
Re: [Release] Character Database Bug Fix (SQL Script)

mmmMM!!.. nice , and cheking the old scripts from webzen
 
Newbie Spellweaver
Joined
Feb 24, 2007
Messages
22
Reaction score
4
Re: [Release] Character Database Bug Fix (SQL Script)

it better explains for what it serves this and so that version?
 
Junior Spellweaver
Joined
Jul 11, 2006
Messages
188
Reaction score
184
Re: [Release] Character Database Bug Fix (SQL Script)

it checks if all the names on "AccountCharacter" exists on Character table, if don't, it will remove it
 
Experienced Elementalist
Joined
Sep 11, 2007
Messages
257
Reaction score
0
Re: [Release] Character Database Bug Fix (SQL Script)

Hm...Interesting,need to try!
 
Newbie Spellweaver
Joined
Nov 18, 2004
Messages
56
Reaction score
0
Re: [Release] Character Database Bug Fix (SQL Script)

Thanks man
 
Newbie Spellweaver
Joined
Sep 30, 2006
Messages
33
Reaction score
1
Re: [Release] Character Database Bug Fix (SQL Script)

Thx Wolf, great !!!
 
Back
Top