Oracle使用游标更新数据
发布时间:2020-12-12 15:42:23 所属栏目:百科 来源:网络整理
导读:使用游标修改数据 定义一个游标,游标名称为 mycursor 更新scott用户中emp表中empno为7369的销售额 -- Created on 2015/11/30 by ZHANW declare he emp%rowtype; cursor mycursor(pid integer) is select * from emp where empno = pid for update ; begin o
使用游标修改数据定义一个游标,游标名称为 mycursor更新scott用户中emp表中empno为7369的销售额-- Created on 2015/11/30 by ZHANW
declare
he emp%rowtype;
cursor mycursor(pid integer) is select * from emp where empno = pid for update;
begin open mycursor(7369);
while(true) loop
fetch mycursor into he;
exit when mycursor%notfound;
update emp set sal = 1111 where current of mycursor;
end loop;
end;
-- Created on 2015/11/30 by ZHANW
declare
he emp%rowtype;
cursor mycursor(pid integer) is select * from emp where empno = pid for update;
begin open mycursor(7369);
while(true) loop
fetch mycursor into he;
exit when mycursor%notfound;
delete from emp where current of mycursor;
end loop;
end;
注意:
优化:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |