语法是这样的:
DEclare mycur  scroll cursor for select * from  yourtablename
open mycur
fetch absulute =1 from mycur
 ……
CLOSE MYCUR
DEALOCATE MYCUR

解决方案 »

  1.   

    看sql的帮助,好像是declare cursor
      

  2.   

    我以为不用游标,写一个存储过程
    if 入库
      if exist(物品记录)
      begin
         select jcsl = 结存数量 from table where 物品= 物品 
                  and 时间 = (select max(时间 ) from table where  物品 =  物品 ) 
     insert table (,,,,结存数量)
            values(,,,,jcsl + 入库数量)
    end
     else  -- not exist(物品记录)insert table (,,,,结存数量)
            values(,,,,入库数量)else ---出库  if exist(物品记录)
      begin
         select jcsl = 结存数量 from table where 物品= 物品 
                  and 时间 = (select max(时间 ) from table where  物品 =  物品 ) 
     insert table (,,,,结存数量)
            values(,,,,jcsl - 出库数量)
    end 
     else  -- not exist(物品记录)
     ------