User Tools

Site Tools


kurs:function_f_get_employee_salary
create or replace 
FUNCTION F_GET_EMPLOYEE_SALARY 
  (v_first_name in employees.first_name%type,
   v_last_name  in employees.last_name%type)
RETURN NUMBER AS 
  v_salary employees.salary%type;
  v_hire_date  employees.hire_date%type;
BEGIN
  select salary, hire_date into v_salary, v_hire_date
    from employees
   where first_name = v_first_name and
         last_name  = v_last_name;
  
  if v_hire_date < sysdate - to_yminterval('10-0') then
    v_salary := v_salary * 1.1;  
  end if;
         
  RETURN v_salary;
END F_GET_EMPLOYEE_SALARY;

select first_name,

      last_name,
      salary,
      hire_date,
      f_get_employee_salary(
       v_last_name  => last_name,
       v_first_name => first_name
      ) as calc_salary  from employees;   
kurs/function_f_get_employee_salary.txt · Last modified: 2016/05/04 15:17 by mh