22,300
社区成员




create procedure pro_up_paidan(
@lv_tj_date DATETIME
)
as
declare @lv_cCusName nvarchar (100)
declare @lv_cInvName nvarchar (100)
declare @lv_cInvStd nvarchar (100)
declare @lv_iQuantity nvarchar (100)
declare @lv_dDate datetime
begin
DECLARE Rst cursor for
select b.cCusName,d.cInvName,d.cInvStd,c.iQuantity,a.dDate
from so_somain a,customer b,SO_SODetails c,inventory d
where a.cCusCode =b.ccuscode and a.id=c.id and c.cInvCode=d.cInvCode and a.dDate=@lv_tj_date
open Rst
fetch next from Rst into @lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate
while @@fetch_status=0
begin
insert into sc_paidan (cCusName,cInvName,cInvStd,iQuantity,dDate,SC_DATE,SC_XH,SC_BH,SC_JSCS,SC_GY,SC_WEIGHT,SC_YL,WHEN_LOGGIN,WHEN_CANCEL,isSelf)values
(@lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate,'',0,'','','','','',@lv_tj_date,null,0)
fetch next from Rst into @lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate
end
close Rst
DEALLOCATE Rst
end
cursor定义错误!
--少declare
declare Rst cursor for select b.cCusName,d.cInvName,d.cInvStd,c.iQuantity,a.dDate from so_somain a,customer b,SO_SODetails c,inventory d where a.cCusCode =b.ccuscode and a.id=c.id and c.cInvCode=d.cInvCode and a.dDate=@lv_tj_date