CREATE PROCEDURE [dbo].[SelXN]
@PID int
AS
SET NOCOUNT ON
DECLARE @indextable TABLE(id int identity(1,1),Mid int,MName NVarChar(50),JG int,FScount int,FSsum int,PJcount int,Stime datetime)
DECLARE @PMid int
set @PMid=0
insert into @indextable (Mid,MName,Stime) select M.MID,M.COMNAME,M.STime from Merchant M where M.MID in (select MID from P_Merchant where PID=@PID)declare @id int,@mid int
DECLARE indext CURSOR FOR (SELECT ID,MID FROM @indextable)
OPEN indext
FETCH NEXT FROM indext into @id,@mid
WHILE @@FETCH_STATUS = 0
BEGIN
set @PMid=@PMid+1
update @indextable set JG=(select Price from P_Merchant where PID=@PID and MID=(select Mid from @indextable where id=@PMid)) where id=@PMid
update @indextable set FScount=(select Count(Capability) from M_Comment where PID=@PID and MID=(select Mid from @indextable where id=@PMid)) where id=@PMid
update @indextable set FSsum=(select sum(Capability) from M_Comment where PID=@PID and MID=(select Mid from @indextable where id=@PMid)) where id=@PMid
update @indextable set PJcount=(select Count(Comment) from M_Comment where PID=@PID and MID=(select Mid from @indextable where id=@PMid)) where id=@PMid
FETCH NEXT FROM indext into @id,@mid
END
select * from @indextable
SET NOCOUNT OFF
GO
@PID int
AS
SET NOCOUNT ON
DECLARE @indextable TABLE(id int identity(1,1),Mid int,MName NVarChar(50),JG int,FScount int,FSsum int,PJcount int,Stime datetime)
DECLARE @PMid int
set @PMid=0
insert into @indextable (Mid,MName,Stime) select M.MID,M.COMNAME,M.STime from Merchant M where M.MID in (select MID from P_Merchant where PID=@PID)declare @id int,@mid int
DECLARE indext CURSOR FOR (SELECT ID,MID FROM @indextable)
OPEN indext
FETCH NEXT FROM indext into @id,@mid
WHILE @@FETCH_STATUS = 0
BEGIN
set @PMid=@PMid+1
update @indextable set JG=(select Price from P_Merchant where PID=@PID and MID=(select Mid from @indextable where id=@PMid)) where id=@PMid
update @indextable set FScount=(select Count(Capability) from M_Comment where PID=@PID and MID=(select Mid from @indextable where id=@PMid)) where id=@PMid
update @indextable set FSsum=(select sum(Capability) from M_Comment where PID=@PID and MID=(select Mid from @indextable where id=@PMid)) where id=@PMid
update @indextable set PJcount=(select Count(Comment) from M_Comment where PID=@PID and MID=(select Mid from @indextable where id=@PMid)) where id=@PMid
FETCH NEXT FROM indext into @id,@mid
END
select * from @indextable
SET NOCOUNT OFF
GO
对照了半天。原来是
FETCH NEXT FROM indext into @id,@mid
着句和我不一样。
但着句我没看明白谁能帮我解释解释。
FETCH NEXT FROM indext
FETCH NEXT FROM indext into @id,@mid
着2句有什么区别么?