1. if --then--end if ;
-- 编写一个过程,可以输入一个雇员名,如果该雇员的工资低于
-- 2000,就给该雇员工资增加10%
create or replace procedure update_sal_pro(chName varchar2) is
--定义变量
v_sal emp.sal%type;
begin
--执行部分
select sal into v_sal from emp where ename=chName;
if v_sal<2000 then
update emp set sal=sal*(1+0.1) where ename=chName;
end if;
end;
2. if --then--else --endif;
-- 编写一个过程,可以输入一个雇员名,如果该雇员的补助不是0
-- 就在原来的基础上增加100;如果补助为0就把补助设为200
create or replace procedure update2_pro(chName varchar2) is
v_comm emp.comm%type;
begin
select comm into v_comm from emp where emp.ename=chName;
if v_comm>0 then
update emp set comm=comm+100 where ename=chName;
else
update emp set comm=200 where ename=chName;
end if;
end;
3. if --then--elsif --else--endif;
-- 输入一个雇员编号,如果是该雇员的职位是PRESIDENT就给他的工资增加1000
-- 如果是MANAGER,就给他加500
-- 其他加200.
create or replace procedure update3_pro(ch_empno number) is
v_job emp.job%type;
begin
select job into v_job from emp where emp.empno=ch_empno;
if v_job='PRESIDENT' then
update emp set sal=sal+1000 where empno=ch_empno;
elsif v_job='MANAGER' then
update emp set sal=sal+500 where empno=ch_empno;
else
update emp set sal=sal+200 where empno=ch_empno;
end if;
end;