Oracle 11g数据库基础教程(第2版)-课后习题-第十章

--1创建一个存储过程,以员工号为参数,输出该员工的工资。
set serveroutput on
create or replace procedure show(p_no emp.empno%type)
as
	v_sal emp.sal%type;
begin
	select sal into v_sal from emp where empno=p_no;
	dbms_output.put_line(v_sal);
exception
	when no_data_found then 
	dbms_output.put_line('there is not such employee');
	end;
/
--调用过程
begin
	show(2010);
end;
/

--2 创建一个存储过程,以员工号为参数,
-- 修改该员工的工资。若该员工属于10号部门,
-- 则工资增加140元;若属于20号部门,则工资增加200元;
-- 若属于30号部门,则工资增加250元;若属于其他部门,则工资增长300元。
set serveroutput on
create or replace procedure show2(p_no emp.empno%type)
as
	v_dno emp.deptno%type;
	v_inc number;
begin
	select deptno into v_dno from emp where empno=p_no;
	case v_dno
		when 10 then v_inc:=140;
		when 20 then v_inc:=200;
		when 30 then v_inc:=250;
		else v_inc:=300;
	end case;
		update emp set sal=sal+v_inc where empno=p_no;
	exception
		when no_data_found then
		dbms_output.put_line('there is not such an employees');
	end;
/
--在调用前后查看一下
select sal,empno,deptno from emp where empno&
  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值