Kod:
--Userdata da Olmayan Charları Account_char da null yapar
--Created by Feyyaz 27.01.2008
CREATE PROCEDURE [1A_C_DELETE]
--@AccountID varchar(21)
AS
SET NOCOUNT ON
DECLARE @AccountID varchar(21)
DECLARE @m1 char(21), @m2 char(21), @m3 char(21), @s1 tinyint, @s2 tinyint, @s3 tinyint, @c1 char(21), @c2 char(21), @c3 char(21), @r1 tinyint, @r2 tinyint, @r3 tinyint,@u char(21)
SET @r1=0
SET @r2=0
SET @r3=0
SET @s1=0
SET @s2=0
SET @s3=0
SET @c1=null
SET @c2=null
SET @c3=null
DECLARE job1 CURSOR FOR
Select straccountid from Account_char
OPEN job1
FETCH NEXT FROM job1
INTO @AccountID
WHILE @@fetch_status = 0
BEGIN
SELECT @c1 = strcharid1, @c2 = strcharid2, @c3 = strcharid3 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
SELECT @r1=count(struserid) FROM [dbo].[USERDATA] WHERE strUserId=@c1
IF @r1=0
UPDATE ACCOUNT_CHAR set strcharid1=null where strAccountID = @AccountID
SELECT @r2=count(struserid) FROM [dbo].[USERDATA] WHERE strUserId=@c2
IF @r2=0
UPDATE ACCOUNT_CHAR set strcharid2=null where strAccountID = @AccountID
SELECT @r3=count(struserid) FROM [dbo].[USERDATA] WHERE strUserId=@c3
IF @r3=0
UPDATE ACCOUNT_CHAR set strcharid3=null where strAccountID = @AccountID
SELECT @m1 = strcharid1, @m2 = strcharid2, @m3 = strcharid3 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
select @s1=count(struserid) from [dbo].[USERDATA] where strUserId=@m1
select @s2=count(struserid) from [dbo].[USERDATA] where strUserId=@m2
select @s3=count(struserid) from [dbo].[USERDATA] where strUserId=@m3
update account_char set bcharnum=@s1+@s2+@s3 where strAccountID=@AccountID
FETCH NEXT FROM job1
INTO @AccountID
END
CLOSE job1
DEALLOCATE job1
SET NOCOUNT OFF
GO
Userdata dan elinizle sildiğiniz charları ebenezer şaşmasın diye account_chardanda siler.ACC_CHAR dan sildiğiniz karakteri silmezseniz char Unknown Class olarak gözükür ve chara girmek istediinizde ebenezer hata verir.Yani bazı fileslarda veriyor.Bunu önlemek için paylaştım ..
--Userdata da Olmayan Charları Account_char da null yapar
--Created by Feyyaz 27.01.2008
CREATE PROCEDURE [1A_C_DELETE]
--@AccountID varchar(21)
AS
SET NOCOUNT ON
DECLARE @AccountID varchar(21)
DECLARE @m1 char(21), @m2 char(21), @m3 char(21), @s1 tinyint, @s2 tinyint, @s3 tinyint, @c1 char(21), @c2 char(21), @c3 char(21), @r1 tinyint, @r2 tinyint, @r3 tinyint,@u char(21)
SET @r1=0
SET @r2=0
SET @r3=0
SET @s1=0
SET @s2=0
SET @s3=0
SET @c1=null
SET @c2=null
SET @c3=null
DECLARE job1 CURSOR FOR
Select straccountid from Account_char
OPEN job1
FETCH NEXT FROM job1
INTO @AccountID
WHILE @@fetch_status = 0
BEGIN
SELECT @c1 = strcharid1, @c2 = strcharid2, @c3 = strcharid3 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
SELECT @r1=count(struserid) FROM [dbo].[USERDATA] WHERE strUserId=@c1
IF @r1=0
UPDATE ACCOUNT_CHAR set strcharid1=null where strAccountID = @AccountID
SELECT @r2=count(struserid) FROM [dbo].[USERDATA] WHERE strUserId=@c2
IF @r2=0
UPDATE ACCOUNT_CHAR set strcharid2=null where strAccountID = @AccountID
SELECT @r3=count(struserid) FROM [dbo].[USERDATA] WHERE strUserId=@c3
IF @r3=0
UPDATE ACCOUNT_CHAR set strcharid3=null where strAccountID = @AccountID
SELECT @m1 = strcharid1, @m2 = strcharid2, @m3 = strcharid3 FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
select @s1=count(struserid) from [dbo].[USERDATA] where strUserId=@m1
select @s2=count(struserid) from [dbo].[USERDATA] where strUserId=@m2
select @s3=count(struserid) from [dbo].[USERDATA] where strUserId=@m3
update account_char set bcharnum=@s1+@s2+@s3 where strAccountID=@AccountID
FETCH NEXT FROM job1
INTO @AccountID
END
CLOSE job1
DEALLOCATE job1
SET NOCOUNT OFF
GO
Userdata dan elinizle sildiğiniz charları ebenezer şaşmasın diye account_chardanda siler.ACC_CHAR dan sildiğiniz karakteri silmezseniz char Unknown Class olarak gözükür ve chara girmek istediinizde ebenezer hata verir.Yani bazı fileslarda veriyor.Bunu önlemek için paylaştım ..