DECLARE
emp_st_date DATE;
wr_emp_id employees.employee_id%TYPE := &enter_employee_id;
BEGIN
SELECT Max(end_date) + 1
INTO emp_st_date
FROM job_history
WHERE employee_id = wr_emp_id;
IF emp_st_date IS NULL THEN
SELECT hire_date
INTO emp_st_date
FROM employees
WHERE employee_id = wr_emp_id;
END IF;
dbms_output.Put_line('----------------------------------------------------------------------');
dbms_output.Put_line('The starting date of current job for the employee '
||wr_emp_id
||' is: '
||emp_st_date);
END;
/
Sample Output:
SQL> /
Enter value for enter_employee_id: 189
old 3: wr_emp_id employees.employee_id%TYPE := &enter_employee_id;
new 3: wr_emp_id employees.employee_id%TYPE := 189;
----------------------------------------------------------------------
The starting date of current job for the employee 189 is: 13-AUG-05
PL/SQL procedure successfully completed.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer