declare
v_job varchar2(30);
v_empno number(4) := &empno;
begin
select job into v_job from scott.emp where empno = v_empno;
case v_job
when 'CLERK'
then
update scott.emp set sal = sal * (1 + 0.15) where empno = v_empno;
Dbms_output.put_line('为普通员工加薪15%');
when 'ANALYST'
then
update scott.emp set sal = sal * (1 + 0.18) where empno = v_empno;
Dbms_output.put_line('为分析员工加薪18%');
when 'MANAGER'
then
update scott.emp set sal = sal * (1 + 0.20) where empno = v_empno;
Dbms_output.put_line('为管理员工加薪20%');
when 'SALESMAN'
then
update scott.emp set sal = sal * (1 + 0.22) where empno = v_empno;
Dbms_output.put_line('为销售员工加薪22%');
else
Dbms_output.put_line('员工职位不在加薪行列');
end case;
COMMIT;
end;
SQL> begin
2 case when 1=&1 then
3 dbms_output.put_line('1=1');
4 update test set id=2;
5 else
6 update test set id=3;
7 dbms_output.put_line('else');
8 end case;
9 commit;
10 end;
11 /
输入 1 的值: 1
原值 2: case when 1=&1 then
新值 2: case when 1=1 then
1=1