/*可更新的游标
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;
13带更新的游标
最新推荐文章于 2022-04-29 08:55:58 发布