17,377
社区成员
发帖
与我相关
我的任务
分享
declare
cursor c is select * from emp where depno=30 for update;
begin
for r in c loop
update emp set sal=sal*1.1 where current of c;
end loop;
commit;
end;
/
create table tbs(id int primary key ,姓名 varchar(10),工资 int,部门 varchar(10));
insert into tbs
select 1,'zhang',1000,'30' from dual union all
select 2,'zhang1',1000,'30' from dual union all
select 3,'zhang2',1000,'30' from dual union all
select 4,'zhang3',1000,'50' from dual union all
select 5,'zhang4',1000,'60' from dual union all
select 6,'zhang5',1000,'30' from dual
declare
cursor cr is select *from tbs;
begin
for cr_1 in cr loop
if cr_1.部门='30' then
update tbs set 工资=工资*1.2 where id=cr_1.id;
end if;
end loop;
end;
update emp set sal=sal*1.10 where deptno=30
create or replace procedure test_proc
as
cursor test_cur is select * from emp;
begin
for v_c in test_cur loop
if v_c.deptno = '30' then
update emp set sal=sal+0.1*sal where ename= v_c.ename;
end if;
end loop;
commit;
end test_proc;
/
create or replace procedure test_proc
as
cursor test_cur is select * from emp;
begin
for v_c in test_cur loop
if v_c.deptno = '30' then
update emp set sal=sal+0.1*sal where ename= v_c.ename;
end if;
end loop;
commit;
end test_proc;
/