假如我要更新游标中的某个记录的值,怎么改?能不能给个具体的例子?跪谢

解决方案 »

  1.   

    for cur1 in (select * from tt for update) loop
      update tt set id=id*2 where id=cur1.id;
    end loop;
      

  2.   


    更新当前记录用current of
    举个例子
    declare 
    cursor a is select * from tt for update; 
    begin
    for cur1 in a loop
      update tt set id=id+1 where current of a;
    end loop;
    end;更新游标的当前记录
      

  3.   

    要更新某个记录的值,可以加个判断
    declare 
    cursor a is select * from tt for update; --定义游标
    begin
    for cur1 in a loop --游标循环
      if cur1.id=2 then
      update tt set id=id+1 where current of a;--更新当前记录
      end if;
    end loop;
    end;
      

  4.   

    怎么commit 能不能具体点
      

  5.   

    declare 
    cursor a is select * from tt for update; --定义游标
    begin
    for cur1 in a loop --游标循环
      if cur1.id=2 then
      update tt set id=id+1 where current of a;--更新当前记录
      end if;
    end loop;
    end;
      

  6.   


    for cur1 in a loop --游标循环
      if cur1.id=2 then
      update tt set id=id+1 where current of a;--更新当前记录
      end if;
    end loop;循环结束后加上commit;
      

  7.   

    恩 多谢啦! 
    其实我要做这样一个存储过程,以游标作为返回类型。
    这个游标是个多表连接,如果是这样的话,update后面的表名字怎么写?
    菜鸟,别见怪!