qq_39840200 2017-08-14 03:54 采纳率: 0%
浏览 3891

SQL 存储过程执行中途停止

ALTER proc [dbo].[wms_in_seek_addre_test]
@vMatno varchar(30),
@vQcstatus varchar(2),
@vBatchano varchar(20),
@vSzno varchar(20),
@vWorks varchar(10),
@vWhouse varchar(10),
@zptype varchar(10),
@zpquant int,

@vNewstore varchar(2) out, --插入库存:0:不插入;1:插入
@vNewadd varchar(2) out, --新货位:0:不是新货位;1:新货位
@vAddreno varchar(20) out, --存储区域
@vAreanopk varchar(20) out, --拣货区域
@vAreano varchar(20)out, --存储区域
@iErrorCode int out,
@iErrorText varchar(300) out --错误提示

as

declare @vZlflag varchar(5)
declare @vPutway varchar(20)
declare @vMatnomix varchar(2) --区域混品标识
declare @vBatchmix varchar(2) --区域混批标识
declare @vBattype varchar(20)
declare @vStorequant int
declare @vUpstore int
declare @vUpclstore int
declare @vBigpack int
declare @vPalquant int
declare @vaType varchar(5)
declare @iInpriority int

declare @tLtAddre table (xd varchar(5),batchcount int,emptycount int)
declare @tLtAddreBatch table (xd varchar(5),batchcount int)
declare @vXd varchar(5)

set @iErrorText = 0
set @iErrorText = ''

print 100

------省略没有问题的语句--------
print '700 ' + convert(varchar(40),getdate(),121)

--cc add 立体库寻址逻辑进行修订
if @vAreano in ('LT01','LT02')
begin
set @vNewstore = '1'
set @vNewadd = '1'

print '710 ' + convert(varchar(40),getdate(),121)
print @vAreano
print @vWhouse

print '715 ' + convert(varchar(40),getdate(),121)
/*
insert into @tLtAddre (xd,emptycount,batchcount) 
select xd,sum(case when a.status = '0' and a.lockflag = 'N' and a.handlock = 'N' then 1 else 0 end),
    sum(case when b.batchno is not null and b.batchno = @vBatchano and b.matno is not null and  b.matno = @vMatno then 1 else 0 end)
from wms_addre a left join wms_store b 
on a.whouseno = b.whouseno and a.addreno = b.addreno 
where a.whouseno = @vWhouse and a.sectn = @vAreano
group by xd
*/

insert into @tLtAddre (xd,emptycount,batchcount) 
select xd,COUNT(*),0
from wms_addre a 
where sectn = @vAreano and whouseno = @vWhouse and status = '0' and lockflag = 'N' and handlock = 'N'
group by xd
having COUNT(*) > 0

print '720 ' + convert(varchar(40),getdate(),121)

insert into @tLtAddreBatch (xd,batchcount)
select a.xd,COUNT(distinct a.addreno)
from wms_addre a,wms_store b
where a.whouseno = b.whouseno and a.addreno = b.addreno and b.batchno = @vBatchano and b.matno = @vMatno and a.whouseno = @vWhouse and a.sectn = @vAreano
group by a.xd

print '730 ' + convert(varchar(40),getdate(),121)

update a 
set a.batchcount = b.batchcount
from @tLtAddre a,@tLtAddreBatch b
where a.xd = b.xd

print '740 ' + convert(varchar(40),getdate(),121)

select top 1 @vXd = xd from @tLtAddre order by batchcount,emptycount desc
if @@rowcount = 0
begin 
    set @iErrorCode = -1
    set @iErrorText = 'LT货位已满100'
    return
end

print '750 ' + convert(varchar(40),getdate(),121)

select top 1 @vAddreno = addreno,@vAreanopk = areano
from wms_addre
where whouseno = @vWhouse and sectn = @vAreano and xd = @vXd and status = '0' and lockflag = 'N' and handlock = 'N'
if @@rowcount = 0
begin 
    set @iErrorCode = -1
    set @iErrorText = 'LT货位已满200'
    return
end
else return

end

执行该语句的时候,就停止了

insert into @tLtAddreBatch (xd,batchcount)
select a.xd,COUNT(distinct a.addreno)
from wms_addre a,wms_store b
where a.whouseno = b.whouseno and a.addreno = b.addreno and b.batchno = @vBatchano and b.matno = @vMatno and a.whouseno = @vWhouse and a.sectn = @vAreano
group by a.xd

系统执行的输出结果:
100

200
300
400
500
600
700 2017-08-14 11:52:34.097
710 2017-08-14 11:52:34.097
LT02
010
715 2017-08-14 11:52:34.097

(15 行受影响)
720 2017-08-14 11:52:34.287
语句已终止。
用户取消了查询。

  • 写回答

1条回答 默认 最新

  • dabocaiqq 2018-06-11 16:37
    关注
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?