declare cs Cursor local for xxx
1 alter procedure [dbo].[pGetBoms] 2 @MaterialCode nvarchar(50) ----物料代码 3 as 4 begin 5 insert into MESBOMs 6 select cInvCodeParent,cInvCode,nQty,bParent From MesBOM where cInvCodeParent=@MaterialCode 7 declare cs Cursor local for select * From MESBOMs where cInvCodeParent=@MaterialCode 8 declare @cInvCodeParent nvarchar(50) 9 declare @cInvCode nvarchar(50) 10 declare @nQty decimal 11 declare @bParent bit 12 open cs 13 fetch next from cs into @cInvCodeParent,@cInvCode,@nQty,@bParent 14 while(@@FETCH_STATUS=0) 15 begin 16 if(@bParent=1) 17 exec pGetBoms @MaterialCode=@cInvCode 18 fetch next from cs into @cInvCodeParent,@cInvCode,@nQty,@bParent 19 end 20 close cs 21 deallocate cs 22 end