游标提取语句重复调用第一行
cursor fetch statement calling first row repetedly
嗨,
我用简单的 select 语句创建了一个只有 10 行的游标
当我要在 while @@fetch_status=0 之后打印时,它递归地
只调用第一行,执行没有停止。
我不知道为什么只显示第一行,光标不会移动到第二行
Here below is my code
declare cur_data cursor for
select DISTINCT pkd.boxnumber from packagedetail pkd
inner join PalletDetail pld on pld.boxnumber=pkd.boxnumber
INNER JOIN TRACKING T ON T.BOXNUM=PKD.SCANBOXID
where pkd.shipmentlocation='NYWH' AND pld.shipmentnumber='SH0675535'
declare @boxnumber NVARCHAR(50)
open cur_data
fetch next from cur_data into @boxnumber
while @@fetch_status=0
begin
print @boxnumber
END
close cur_data
deallocate cur_data
你还必须在你的 while 循环中获取 ...next ...
...
open cur_data
fetch next from cur_data into @boxnumber
while @@fetch_status=0
BEGIN
print @boxnumber
fetch next from cur_data into @boxnumber
END
...
嗨,
我用简单的 select 语句创建了一个只有 10 行的游标 当我要在 while @@fetch_status=0 之后打印时,它递归地 只调用第一行,执行没有停止。 我不知道为什么只显示第一行,光标不会移动到第二行
Here below is my code
declare cur_data cursor for
select DISTINCT pkd.boxnumber from packagedetail pkd
inner join PalletDetail pld on pld.boxnumber=pkd.boxnumber
INNER JOIN TRACKING T ON T.BOXNUM=PKD.SCANBOXID
where pkd.shipmentlocation='NYWH' AND pld.shipmentnumber='SH0675535'
declare @boxnumber NVARCHAR(50)
open cur_data
fetch next from cur_data into @boxnumber
while @@fetch_status=0
begin
print @boxnumber
END
close cur_data
deallocate cur_data
你还必须在你的 while 循环中获取 ...next ...
...
open cur_data
fetch next from cur_data into @boxnumber
while @@fetch_status=0
BEGIN
print @boxnumber
fetch next from cur_data into @boxnumber
END
...