13带更新的游标

来源:互联网 发布:c语言指针教学视频 编辑:程序博客网 时间:2024/06/07 23:56
/*可更新的游标  current of 游标名:表示游标的当前行。  当使用游标更新或删除数据时,在定义游标时必须要带有for update子句,  用于在游标结果集数据上加行共享锁,以防止其他用户在相应行上执行dml操作;*/declare  cursor cs_user is    Select * From T_userinfo for update;begin  for v_row in cs_user loop    if v_row.userid = 6 then      --null;      update T_Userinfo         set username = '可更新游标'       where current of cs_user;    else      if v_row.userid =  7 then        delete From T_userinfo where current of cs_user;      end if;    end if;  end loop;  commit;end; --可更新的游标在jdbc中的使用。  --Select * From T_userinfo for update of username;  

原创粉丝点击