All pastes #636643 Raw Edit

GoatCheez's StoredProc for IP BA

public sql v1 · immutable
#636643 ·published 2007-07-28 02:28 UTC
rendered paste body
--GoatCheezCREATE PROCEDURE UPDATE_CHARBAN@nRet		smallint OUTPUT, @CharID		char(21)ASDECLARE @BanCount int, @IpAddress char(50), @TodaysDate datetime, @ExistCount tinyintSET @TodaysDate = CURRENT_TIMESTAMPSET @BanCount = 0SET @ExistCount = 0SELECT @IpAddress = strClientIP FROM CURRENTUSER WHERE strCharID = @CharIDSELECT @ExistCount = COUNT (*) FROM IP_BAN WHERE IP = @IpAddressIF @ExistCount < 1BEGIN	INSERT INTO IP_BAN (IP,BanCount,IPBanCount,LastBanDate) VALUES (@IpAddress, 0, 0, @TodaysDate)ENDELSE	BEGIN	SELECT @BanCount = BanCount FROM IP_BAN WHERE IP = @IpAddress	SET @BanCount = @BanCount + 1	UPDATE IP_BAN SET BanCount = @BanCount, LastBanDate = @TodaysDate WHERE IP = @IpAddressENDIF @@ERROR <> 0BEGIN	 	ROLLBACK TRAN 	SET @nRet =  1	RETURNENDCOMMIT TRANSET @nRet =  0GO