mysql 游标循环读取下一行的问题
declare@orderidNVARCHAR(50)DECLAREmycursorCURSORFORselectIDfromGM_OrderOPENmycursorFE...
declare @orderid NVARCHAR(50)DECLARE mycursor CURSOR FORselect ID from GM_Order OPEN mycursorFETCH NEXT FROM mycursor INTO @orderidselect ID from GM_Order WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM mycursor INTO @orderid SELECT @orderid END CLOSE mycursorDEALLOCATE mycursor--想要输出的结果是1,2为什么都是2
展开
展开全部
这 句话的位置错了..
FETCH NEXT FROM mycursor INTO @orderid
declare @orderid NVARCHAR(50)
DECLARE mycursor CURSOR FOR
select ID from GM_Order
OPEN mycursor
FETCH NEXT FROM mycursor INTO @orderid
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @orderid
FETCH NEXT FROM mycursor INTO @orderid
END
CLOSE mycursor
DEALLOCATE mycursor
FETCH NEXT FROM mycursor INTO @orderid
declare @orderid NVARCHAR(50)
DECLARE mycursor CURSOR FOR
select ID from GM_Order
OPEN mycursor
FETCH NEXT FROM mycursor INTO @orderid
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @orderid
FETCH NEXT FROM mycursor INTO @orderid
END
CLOSE mycursor
DEALLOCATE mycursor
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询