[MANUAL] Бескокечные соски

Тема в разделе "Установка и настройка (Setup and configuration)", создана пользователем root, 27 сен 2014.

  1. root

    root Administrator Команда форума Administrator Moderator Developers Team

    Регистрация:
    23 авг 2014
    Сообщения:
    253
    Симпатии:
    56
    Баллы:
    11
    MSSQL:
    Код:
    ALTER PROCEDURE [DBO].[lin_AmountChange] (
     @char_id INT,
     @item_id INT,
     @change INT,
     @item_type INT,
     @bZeorDelete INT = 0
     )
     AS
     SET NOCOUNT ON
    
    
     DECLARE @nResultAmount INT
     SET @nResultAmount = -1
    
    
     IF(select top 1 amount from user_item where char_id = @char_id AND item_id = @item_id ) + @change >= 0
     begin
     select @item_type=item_type from user_item where item_id = @item_id
     if @item_type in (1463, 1464, 1465, 1466, 1467,2510, 2511, 2512, 2513, 2514, 3948, 3949, 3950, 3951, 3952) 
     begin
     SELECT 10
     end
     else begin
     UPDATE user_item SET amount = amount + @change WHERE char_id = @char_id AND item_id = @item_id
    
    
     IF NOT @@ROWCOUNT = 1 
     SELECT -1
     ELSE
     SELECT @nResultAmount = ISNULL(amount, -1) FROM user_item WHERE char_id = @char_id AND item_id = @item_id
     IF ( @nResultAmount = 0 AND @bZeorDelete = 1) 
     BEGIN
     DELETE user_item WHERE char_id = @char_id AND item_id = @item_id
     -- UPDATE user_item SET char_id = 0, item_type = 0 WHERE char_id = @char_id AND item_id = @item_id
     END
    
    
     SELECT @nResultAmount
     end
     end
     else
     select -1
     GO