日期:2014-05-16 浏览次数:20881 次
CREATE OR REPLACE FUNCTION FUN_GET_RAISED_SALARY(p_empno emp.empno%TYPE)
RETURN NUMBER;
IS
v_job emp.job%TYPE;
v_sal emp.sal%TYPE;
v_salaryratio NUMBER(10,2);
BEGIN
SELECT job, sal INTO v_job, v_sal FROM emp WHERE empno = p_empno;
CASE v_job
WHEN 'CLERK' THEN
v_salaryratio := 1.09;
WHEN 'SALESMAN' THEN
v_salaryratio := 1.11;
WHEN 'MANAGER' THEN
v_salaryratio := 1.18;
ELSE
v_salaryratio := 1;
END CASE;
IF v_salaryratio <> 1
THEN
RETURN ROUND(v_sal * v_salaryratio, 2);
ELSE
RETURN v_sal;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN 0;
END FUN_GET_RAISED_SALARY;