大家帮忙看看这道题怎么做呀?~~~

贝鱼 2010-07-31 04:00:19
使用游标循环检索所有雇员的姓名、工资和部门号,并给部门30的所有雇员工资增加10%(表emp,列:ename,sal,deptno)
...全文
97 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xman_78tom 2010-07-31
  • 打赏
  • 举报
回复

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;
/
duanzhi1984 2010-07-31
  • 打赏
  • 举报
回复
我是个初学者,为了学习游标,我自己写一个全当练习..
借此地贴出来

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;
duanzhi1984 2010-07-31
  • 打赏
  • 举报
回复
ORACLE游标感觉比SQL 游标麻烦
「已注销」 2010-07-31
  • 打赏
  • 举报
回复
练习游标
  • 打赏
  • 举报
回复
干嘛非要用游标啊!
update emp  set sal=sal*1.10 where deptno=30

这样不可以吗?
duqiangcise 2010-07-31
  • 打赏
  • 举报
回复
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;
/
duqiangcise 2010-07-31
  • 打赏
  • 举报
回复
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;
/
zx79 2010-07-31
  • 打赏
  • 举报
回复
我也很想知道 帮你顶

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧