日期:2014-05-18 浏览次数:20752 次
BEGIN SELECT @OrderRowCount = COUNT(*) FROM T_ORDER T WHERE T.DispOrderStatus != @CancelStatus AND T.DispOrderStatus!=@SuccessStatus AND sellUserID=@sellUserID AND TRADE_TYPE=@TradeType IF(@OrderRowCount>0) SET @ReturnValue= -1 SELECT @rowCountArbitrate = COUNT(*) from T_ORDER T WHERE T.Arbitrate = 6 AND t.sellUserID=@sellUserID AND t.TRADE_TYPE=@TradeType IF @rowCountArbitrate>0 set @ReturnValue = -3 if exists (SELECT * FROM T_ORDER t WHERE t.sellUserID=@sellUserID AND t.DispOrderStatus =@SuccessStatus AND t.TRADE_TYPE=@TradeType AND t.ORDER_DATE>@date) set @ReturnValue = -4 --可以保证,执行到这里的时候 @ReturnValue = -1,但为什么还会进入这个IF执行下面的,并且最后给我返回一个1 --是不是我@@ERROR用的有问题。 IF(@ReturnValue = 0 OR @ReturnValue IS NULL) UPDATE T_CARD_STOCK SET [status] = @ShelfStatus WHERE [uid]=@sellUserID IF(@@ERROR = 0) SET @ReturnValue = 1 --最后执行到了这里 ELSE SET @ReturnValue = -2 return @ReturnValue END
BEGIN SELECT @OrderRowCount = COUNT(*) FROM T_ORDER T WHERE T.DispOrderStatus != @CancelStatus AND T.DispOrderStatus!=@SuccessStatus AND sellUserID=@sellUserID AND TRADE_TYPE=@TradeType IF(@OrderRowCount>0) SET @ReturnValue= -1 SELECT @rowCountArbitrate = COUNT(*) from T_ORDER T WHERE T.Arbitrate = 6 AND t.sellUserID=@sellUserID AND t.TRADE_TYPE=@TradeType IF @rowCountArbitrate>0 set @ReturnValue = -3 if exists (SELECT * FROM T_ORDER t WHERE t.sellUserID=@sellUserID AND t.DispOrderStatus =@SuccessStatus AND t.TRADE_TYPE=@TradeType AND t.ORDER_DATE>@date) set @ReturnValue = -4 print @ReturnValue --看下结果 --可以保证,执行到这里的时候 @ReturnValue = -1,但为什么还会进入这个IF执行下面的,并且最后给我返回一个1 --是不是我@@ERROR用的有问题。 IF(@ReturnValue = 0 OR @ReturnValue IS NULL) BEGIN UPDATE T_CARD_STOCK SET [status] = @ShelfStatus WHERE [uid]=@sellUserID IF(@@ERROR = 0) SET @ReturnValue = 1 --最后执行到了这里 ELSE SET @ReturnValue = -2 END -- try return @ReturnValue END