各位仁兄帮小妹一把,帮我看看这条sql cursor 语句对不对?到十一前就的上交了......
不好意思,刚进来,没有太多分给各位。拜托拜托!
Declare mycur  scroll cursor
 for
 select mx_finanum, mx_finasum,mx_date from  j_kcmx
 where mx_date>=@mx_date 
 open mycur     fetch mycur into @mx_finanum,@mx_finasum,@date
     while(@@fetch_status=0)
     begin
          select @mx_finanum =mx_finanum,@mx_finasum=mx_finasum  from j_kcmx where wp_no=@wp_no 
              and mx_date = (select min(mx_date ) from j_kcmx where wp_no = @wp_no and mx_date<=@date) 
         update j_kcmx set mx_finanum=@mx_finanum+mx_addnum-mx_recnum,mx_finasum=@mx_finasum+mx_addsum-mx_recsum        Fetch Next From mycur Into @mx_finanum,@mx_finasum,@date     end
CLOSE mycur
DEALLOCATE mycur

解决方案 »

  1.   

    没看到什么错误,
    不过,我用CURSOR时,
    一般用fast_forward read_only选项,
    速度可能会快点
      

  2.   

    应该没错!自己到查询分析器里测试一下吧================================================================
         ◆◆◆ CSDN查询助手,查询方便快捷◆◆◆ 下载地址:  
     http://CoolSlob.ifood1.com/Download/CSDNFinder.exe  
     http://CoolSlob.8u8.com/Download/Tools/CSDNFinder.Slob[更名为.exe即可]  
      

  3.   


    就是这儿     fetch mycur into @mx_finanum,@mx_finasum,@date
    然后又对@mx_finanum,@mx_finasum付值,不知道对不对。
      

  4.   

    我看的不仔细,但我想
    这个问题是不是,可以不用CURSOR解决,
      

  5.   

    @mx_finanum,@mx_finasum着两个变量好象没有用呀,
    为什么放到CURSOR里,
    我认为最好还是不用CURSOR,