ALTER PROCEDURE [dbo].[SP_SageGoods_Read]
As
--insert into dbo.sage_goods_input
--select ITMREF_0 as 物料编码, ITMDES1_0 as 物料名称 ,STU_0 as 单位, TCLCOD_0 as 分类编码
--from Sage.anlux3.ANLU.ITMMASTER
--where ITMREF_0 not like '5X%'
declare @memo varchar(50)
set @memo='ERP导入'
declare @pid bigint
declare @goodsid varchar(255)
declare @goodsname varchar(255)
declare @unit varchar(255)
declare @classid varchar(255)
declare @classname varchar(255)
declare mycursor cursor for select pid,goodsid,goodsname,unit,classid from dbo.sage_goods_input
open mycursor
fetch next from mycursor into @pid,@goodsid,@goodsname,@unit,@classid
while @@fetch_status=0
begin
select @classname=classname from dbo.pub_class_def where classid=@classid
if not exists (select goodsid from dbo.pub_goods_def where goodsid=@goodsid)
begin
DECLARE @return_value int
EXEC @return_value = [dbo].[SP_Goods_Create]
@goodsid=@goodsid,@goodsname=@goodsname,@unit=@unit,@classname=@classname,@memo=@memo
if (@return_value=0)
begin
delete dbo.sage_goods_input where pid=@pid
end
end
else
begin
DECLARE @return_value0 int
EXEC @return_value0 = [dbo].[SP_Goods_Update]
@goodsid=@goodsid,@goodsname=@goodsname,@unit=@unit,@classname=@classname,@memo=@memo
if (@return_value0=0)
begin
delete dbo.sage_goods_input where pid=@pid
end
end fetch next from mycursor into @pid,@goodsid,@goodsname,@unit,@classid
end
close mycursor
deallocate mycursor这里还有一个
As
--insert into dbo.sage_goods_input
--select ITMREF_0 as 物料编码, ITMDES1_0 as 物料名称 ,STU_0 as 单位, TCLCOD_0 as 分类编码
--from Sage.anlux3.ANLU.ITMMASTER
--where ITMREF_0 not like '5X%'
declare @memo varchar(50)
set @memo='ERP导入'
declare @pid bigint
declare @goodsid varchar(255)
declare @goodsname varchar(255)
declare @unit varchar(255)
declare @classid varchar(255)
declare @classname varchar(255)
declare mycursor cursor for select pid,goodsid,goodsname,unit,classid from dbo.sage_goods_input
open mycursor
fetch next from mycursor into @pid,@goodsid,@goodsname,@unit,@classid
while @@fetch_status=0
begin
select @classname=classname from dbo.pub_class_def where classid=@classid
if not exists (select goodsid from dbo.pub_goods_def where goodsid=@goodsid)
begin
DECLARE @return_value int
EXEC @return_value = [dbo].[SP_Goods_Create]
@goodsid=@goodsid,@goodsname=@goodsname,@unit=@unit,@classname=@classname,@memo=@memo
if (@return_value=0)
begin
delete dbo.sage_goods_input where pid=@pid
end
end
else
begin
DECLARE @return_value0 int
EXEC @return_value0 = [dbo].[SP_Goods_Update]
@goodsid=@goodsid,@goodsname=@goodsname,@unit=@unit,@classname=@classname,@memo=@memo
if (@return_value0=0)
begin
delete dbo.sage_goods_input where pid=@pid
end
end fetch next from mycursor into @pid,@goodsid,@goodsname,@unit,@classid
end
close mycursor
deallocate mycursor这里还有一个
select @classname=classname from dbo.pub_class_def where classid=@classid
if not exists (select goodsid from dbo.pub_goods_def where goodsid=@goodsid)
begin
DECLARE @return_value int
EXEC @return_value = [dbo].[SP_Goods_Create]
@goodsid=@goodsid,@goodsname=@goodsname,@unit=@unit,@classname=@classname,@memo=@memo
if (@return_value=0)
begin
delete dbo.sage_goods_input where pid=@pid
end这里的语句该怎么理解?