I am a trying to learn SQL/ORACLE on my own and I am completely lost on one issue. I have to write a program that calculates a yearly bonus amount based on three factors: years employee has worked, job type, and if the employee deserves extra merit.

I have a habit of trying to figure out the code in sections so right now I am trying to figure out the date calculation portion.
I am trying to calculate the difference between the employee start date and the current date in years so I can determine for how mucu bonus pay the employee should receive.

This is where I am so far and the results in SQL/ORACLE:


SQL> DECLARE
2 todays_date DATE;
3 employee_start_date DATE;
4 years_worked VARCHAR2(5);
5 BEGIN
6 todays_date := TRUNC(SYSDATE, 'YEAR');
7 todays_date := TO_CHAR(todays_date);
8 employee_start_date := TO_CHAR(employee_start_date);
9 employee_start_date := '05-JAN-93';
10 years_worked := (todays_date - employee_start_date);
11 DBMS_OUTPUT.PUT_LINE('There are ' || years_worked || ' years worked ' || 'between ' || employe
e_start_date || ' and ' || TO_CHAR(todays_date));
12 END;
13 /
There are 5109 years worked between 05-JAN-93 and 01-JAN-07

PL/SQL procedure successfully completed.


What is the problem here??