您的位置:首页 > 其它

for update 的使用例子

2009-01-14 16:18 302 查看
WHERE CURRENT OF WHERE CURRENT OF YOUR_CURSOR_NAME 其实还是很有用的,特别是在循环游标中。

例如:需要把所有job=SALESMAN的加5%的工资。

=CLERK的加10%的工资。

=MANAGER加15%的工资。

[Copy to clipboard] [ - ]
CODE:
declare

cursor myc is

select * from emp for update;

begin

for v_row in myc loop

if v_row.job='SALESMAN' then

update emp set sal=sal*1.05 where current of myc;

elsif v_row.job='CLERK' then

update emp set sal=sal*1.10 where current of myc;

elsif v_row.job='MANAGER' then

update emp set sal=sal*1.15 where current of myc;

end if;

end loop;

commit;

exception

when others then

rollback;

raise;

end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: