金蝶K3--采购管理--审核采购单价库

declare @fsupid int,@fitemid int,@funitid int,@fprice decimal(18,10),@fptype int,@fentryid int,@icount int
set @icount = 1
declare my_select cursor for select fsupid,fitemid,funitid,fprice,fptype,fentryid from t_supplyentry where fused=0
open my_select
fetch next from my_select into @fsupid,@fitemid,@funitid,@fprice,@fptype,@fentryid
while @@fetch_status=0
begin
	if (select count(1) as counts from t_supplyentry where fsupid=@fsupid and fitemid=@fitemid and funitid=@funitid and fprice=@fprice and fptype=@fptype and fused=0)=1
	begin
		update t_supplyentry set fused=1 where fentryid=@fentryid
		set @icount = @icount + 1
	end
	else
	begin
		if @icount=1
		begin
			if object_id(N'tempdb.dbo.#my_table') is not null begin drop table #my_table end
			select * into #my_table from t_supplyentry where fsupid=@fsupid and fitemid=@fitemid and funitid=@funitid and fprice=@fprice and fptype=@fptype and fused=0
		end
		else
		begin
			insert into #my_table (fbrno,fsupid,fitemid,fentryid,funitid,fstartqty,fendqty,fprice,fcyid,fdiscount,fleadtime,fquotetime,fused,fdisabledate,fremark,fptype,flastmodifieddate,flastmodifiedby) select * from t_supplyentry where fsupid=@fsupid and fitemid=@fitemid and funitid=@funitid and fprice=@fprice and fptype=@fptype and fused=0
		end
	end
	fetch next from my_select into @fsupid,@fitemid,@funitid,@fprice,@fptype,@fentryid
end
select * from #my_table
drop table #my_table
close my_select
deallocate my_select
print '共审核'+cast(@icount as varchar)+'行数据'

 

转载于:https://my.oschina.net/ansenchina/blog/3029617

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值