declare tmpcsr cursor select * from table..
open tmpCsr
while 1=1
begin
 fetch next from tmpCsr into @fieldx
 if @@fetch_status <> 1 
    goto l_end
...
end
l_end:
...