关于游标

Declare @ProductPrice smallmoney,@ProductMoney smallmoney
Declare Price_Cursor CURSOR for 
select F_ProductPrice,F_ProductMoney from NewOrder
for Update of F_ProductPrice  --这个是什么意思呢?这个就是要更新的列
open Price_Cursor
FETCH FROM Price_Cursor
    
Into @ProductPrice,@ProductMoney
    
While @@FETCH_STATUS = 0
        
BEGIN 
            
if (@ProductPrice>1000)
                
Begin 
                    
Update NewOrder set F_ProductPrice = @ProductPrice*0.85 
                    
where Current of Price_Cursor
                
End
            
else
                
Begin 
                    
Update NewOrder set F_ProductPrice = @ProductPrice*0.9
                    
where Current of Price_Cursor
                
End
            
            
Fetch Next from Price_Cursor
            
into @ProductPrice,@ProductMoney
        
END

Close price_Cursor
Deallocate Price_Cursor
posted @ 2007-10-17 15:09  海底的鱼  阅读(125)  评论(0)    收藏  举报