存储过程 函数

cursor c_emp is select job,empno,ename from emp for update;
c_manager constant number :=0.30;
c_salesman constant number :=0.4;
v_job varchar(100);
v_empno varchar(100);
v_ename varchar(100);
v_ratio number(7,2);

begin
open c_emp;
loop
fetch c_emp
into v_job, v_empno,v_ename;
exit when c_emp%notfound;
v_ratio :=getaddsalaryratio(v_job);
if v_job='MANAGER'
then update emp set sal=sal*(1+v_ratio)
where current of c_emp;

elsif v_job='SALESMAN'
then update emp set sal=sal*(1+v_ratio)
where current of c_emp;
end if;
dbms_output.put_line('为员工'||v_empno||'成功加薪');
end loop;
close c_emp;
exception
when no_data_found
then
dbms_output.put_line('没有找到数据');

原文地址:https://www.cnblogs.com/shejiewei/p/9869891.html