拜托大师找bug
sqlserver吧
全部回复
仅看楼主
level 2
lht0012002 楼主
ALTER PROCEDURE [dbo].[勾对完结]
(@user1 char(10),@yue decimal(20,2)
)
AS
set NOCOUNT on
set @yue=isnull((select isnull(max(A10.差额),0) as 差额 from (select A9.差额 from [勾对差额通过] A9
where A9.批次 in (select A8.[批次] from [挑选订单] A8 where (
A8.[勾对完结]=0) and charindex(rtrim(@user1),A8.[批次])>0
group by A8.[批次])) A10),0)
if
(select sum(A4.[收入]) as 收入 from [账户流水2] A4 where (rtrim(A4.[绑定人])=rtrim(@user1)
and ( (A4.[勾对完结])=0)) )
=
(((select sum(A6.[应收合计]) as 应收 from (select A7.订单号,A7.应收合计,'aaa' as bz from [订单汇总] A7
where A7.订单号 in (select A5.[订单号] from [挑选订单] A5
where (A5.[勾对完结]=0) and charindex(rtrim(@user1),A5.[批次])>0 )
and ( (charindex(rtrim(@user1),A7.[批次])=0))
) A6 group by A6.bz)
+
@yue
)
)
begin
update [订单汇总] set [批次]=
(select A2.[批次] from [挑选订单] A2 where ( A2.[勾对完结]=0) and charindex(rtrim(@user1),A2.[批次])>0
group by A2.[批次]) where 订单号 in (select A3.[订单号]
from [挑选订单] A3 where ( A3.[勾对完结]=0) and charindex(rtrim(@user1),A3.[批次])>0 )
update [渠道订单] set [批次]=
(select A2.[批次] from [挑选订单] A2 where ( A2.[勾对完结]=0) and charindex(rtrim(@user1),A2.[批次])>0
group by A2.[批次]) where 订单号 in (select A3.[订单号]
from [挑选订单] A3 where ( A3.[勾对完结]=0) and charindex(rtrim(@user1),A3.[批次])>0 )
update [账户流水2] set [勾对完结]=1 where ( [勾对完结]=0) and charindex(rtrim(@user1),[批次])>0
update [挑选订单] set [勾对完结]=1 where ( [勾对完结]=0) and charindex(rtrim(@user1),[批次])>0
update 账户流水2 set [勾对完结]=0 where len(rtrim(批次))=0
select '勾对已经正常完结!!' as fk
end
else begin
select '勾对不正常!!' as fk
end
2020年03月11日 03点03分 1
level 2
lht0012002 楼主
为什么满足条件为真的也会运行else后面的语句,我的if else 控制有什么问题呀
2020年03月11日 03点03分 2
1