慕粉3995511
2020-04-03 18:25
SET serveroutput ON DECLARE--定义光标代表给哪些员工涨工资
-- alter table emp rename column "jop" to empjop;
cursor cemp IS SELECT
empno,
jop
FROM
emp;
pempno emp.empno % TYPE;
pjop emp.jop % TYPE;
BEGIN--打开光标
open cemp;
loop--取出一个员工
FETCH cemp INTO pempno,
pjop;
exit
WHEN cemp % notfound;
--判断员工的职位
IF
pjop = 'PRESIDENT' THEN
UPDATE emp
SET sal = sal + 1000
WHERE
empno = pempno;
elseif pjop = 'MANAGER' THEN
UPDATE emp
SET sal = sal + 800
WHERE
empno = pempno;
ELSE UPDATE emp
SET sal = sal + 400
WHERE
empno = pempno;
END IF;
END loop;
--关闭光标
close cemp;
END;
elsif写错了
Oracle数据库开发必备利器之PL/SQL基础
75048 学习 · 208 问题
相似问题