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

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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。