- Joined
- Oct 17, 2012
- Messages
- 660
- Reaction score
- 263
Здрасти ;P
Пробвах да преправя една процедура, но нещо не стана както трябва!
Искането ми беше да направя едно wPoint, което е Point само че с друго име (с цел Week Point DS)
Ето как го бях направил
Някой ако вижда евентуална грешка нека я поправи, ще съм му много благодарен.
Пробвах да преправя една процедура, но нещо не стана както трябва!
CREATE PROCEDURE SP_POINT_ACCUMULATION
@Server tinyint, -- ???
@Square tinyint, -- ??
@AccountID varchar(10),
@CharacterName varchar(10),
@Class tinyint ,
@Point int
As
Begin
BEGIN TRANSACTION
SET NOCOUNT ON
IF EXISTS ( SELECT CharacterName FROM EVENT_INFO WITH (READUNCOMMITTED)
WHERE Server = @Server AND AccountID = @AccountID AND CharacterName = @CharacterName )
Begin
UPDATE EVENT_INFO
SET Point = Point + @Point , Square = @Square
WHERE Server = @Server AND AccountID = @AccountID AND CharacterName = @CharacterName
End
ELSE
Begin
INSERT INTO EVENT_INFO ( Server, Square, AccountID, CharacterName, Class, Point ) VALUES (
@Server,
@Square,
@AccountID,
@CharacterName,
@Class,
@Point
)
End
IF(@@Error <> 0 )
ROLLBACK TRANSACTION
ELSE
COMMIT TRANSACTION
SET NOCOUNT OFF
End
GO
Искането ми беше да направя едно wPoint, което е Point само че с друго име (с цел Week Point DS)
Ето как го бях направил
CREATE PROCEDURE SP_POINT_ACCUMULATION
@Server tinyint, -- ???
@Square tinyint, -- ??
@AccountID varchar(10),
@CharacterName varchar(10),
@Class tinyint ,
@Point int ,
@wPoint int
As
Begin
BEGIN TRANSACTION
SET NOCOUNT ON
IF EXISTS ( SELECT CharacterName FROM EVENT_INFO WITH (READUNCOMMITTED)
WHERE Server = @Server AND AccountID = @AccountID AND CharacterName = @CharacterName )
Begin
UPDATE EVENT_INFO
SET Point = Point + @Point , Square = @Square , wPoint = Point + @wPoint
WHERE Server = @Server AND AccountID = @AccountID AND CharacterName = @CharacterName
End
ELSE
Begin
INSERT INTO EVENT_INFO ( Server, Square, AccountID, CharacterName, Class, Point, wPoint ) VALUES (
@Server,
@Square,
@AccountID,
@CharacterName,
@Class,
@Point,
@wPoint
)
End
IF(@@Error <> 0 )
ROLLBACK TRANSACTION
ELSE
COMMIT TRANSACTION
SET NOCOUNT OFF
End
GO