CREATE OR REPLACE FUNCTION getsal(id_param NUMBER) RETURN NUMBER IS sal_increase employees.salary%TYPE; tenure NUMBER; sal NUMBER; BEGIN SELECT salary, MONTHS_BETWEEN(SYSDATE, hire_date)/12 INTO sal_increase, tenure FROM employees WHERE employee_id = id_param; IF tenure <= 12 THEN sal_increase := 0; ELSIF tenure BETWEEN 13 AND 36 THEN sal_increase := sal_increase+(sal_increase * .05); ELSIF tenure BETWEEN 37 AND 60 THEN sal_increase := sal_increase+(sal_increase * .1); ELSIF tenure BETWEEN 61 AND 120 THEN sal_increase := sal_increase+(sal_increase * .15); ELSE sal_increase := sal_increase+(sal_increase * .2); END IF; RETURN sal_increase; END; DECLARE newsalary NUMBER; BEGIN newsalary := getsal(101); DBMS_OUTPUT.PUT_LINE('New Salary:'|| newsalary); END;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)