您的位置:首页 > 数据库 > Oracle

oracle中游标的使用,示例

2011-11-04 09:30 274 查看
1.如果雇员工资低于2000,则给雇员增加10%的工资。(scott用户中的emp表)

declare

cursor emp_cursor is select ename,sal from emp for update;

emp_record emp_cursor%rowtype;

begin

open emp_cursor;

loop

fetch emp_cursor into emp_record;

exit when emp_cursor%notfound;

if emp_record.sal<2000 then

update emp set sal=sal*1.1 where current of emp_cursor;

end if;

end loop;

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