View difference between Paste ID: R4HqMA5b and 9Q5WVQ9S
SHOW: | | - or go back to the newest paste.
1
ALTER PROCEDURE [dbo].[CHANGE_NEW_ID]
2
@byType char(21),
3
@AccountID char(21),
4
@OldCharID char(21),
5
@NewCharID char(21),
6
@nRet smallint output
7
AS
8
/*
9
--- www.egeonline.org
10
*/
11
DECLARE @CheckUserID int
12
13
IF LEN(LTRIM(@NewCharID)) < 3  -- LEN() does an RTRIM()
14
BEGIN
15-
  SET nRet = 7
15+
  SET @nRet = 7
16
  RETURN
17
END
18
19
SELECT @CheckUserID = COUNT(strUserID) FROM USERDATA WHERE strUserID = @NewCharID
20
IF @CheckUserID = 0 
21
BEGIN
22
-- Change Account All Information
23
UPDATE ACCOUNT_CHAR SET strCharID1 = @NewCharID WHERE strCharID1 = @OldCharID AND strCharID1 is not null
24
UPDATE ACCOUNT_CHAR SET strCharID2 = @NewCharID WHERE strCharID2 = @OldCharID AND strCharID2 is not null
25
UPDATE ACCOUNT_CHAR SET strCharID3 = @NewCharID WHERE strCharID3 = @OldCharID AND strCharID3 is not null
26
UPDATE USERDATA SET strUserId = @NewCharID WHERE strUserId = @OldCharID AND strUserId is not null
27
-- Change Information a User in Knights
28
UPDATE KNIGHTS_USER SET strUserId = @NewCharID WHERE strUserId = @OldCharID AND strUserId  is not null
29
UPDATE KNIGHTS SET Chief = @NewCharID WHERE Chief = @OldCharID AND Chief is not null
30
UPDATE KNIGHTS SET ViceChief_1 = @NewCharID WHERE ViceChief_1 = @OldCharID AND ViceChief_1 is not null
31
UPDATE KNIGHTS SET ViceChief_2 = @NewCharID WHERE ViceChief_2 = @OldCharID AND ViceChief_2 is not null
32
UPDATE KNIGHTS SET ViceChief_3 = @NewCharID WHERE ViceChief_3 = @OldCharID AND ViceChief_3 is not null
33
-- Change Information a User is King
34
UPDATE KING_SYSTEM SET strKingName = @NewCharID WHERE strKingName = @OldCharID AND strKingName is not null
35
UPDATE KING_ELECTION_LIST SET strName = @NewCharID WHERE strName = @OldCharID AND strName is not null
36
-- Change User Friend List Information
37
UPDATE FRIEND_LIST SET strUserID = @NewCharID where strUserID = @OldCharID
38
-- User Rental Item
39
UPDATE RENTAL_ITEM SET strLenderCharID = @NewCharID WHERE strLenderCharID = @OldCharID AND strLenderCharID is not null
40
UPDATE RENTAL_ITEM SET strBorrowerCharID = @NewCharID WHERE strBorrowerCharID = @OldCharID AND strBorrowerCharID is not null
41
UPDATE RENTAL_ITEM_LIST SET strBorrowerCharID = @NewCharID WHERE strBorrowerCharID = @OldCharID AND strBorrowerCharID is not null
42
-- Change CurrentUser
43
UPDATE CURRENTUSER SET strCharID = @NewCharID WHERE strCharID = @OldCharID
44
-- Name Change is Sucessfull
45
SET @nRet = 0
46
RETURN
47
END
48
ELSE
49
BEGIN
50
-- Entered ID is Already Being Used Another Character
51
SET @nRet = 1
52
RETURN
53
END