SQL>
SQL> DECLARE
2 start_date DATE;
3 end_date DATE;
4 service_interval INTERVAL YEAR TO MONTH;
5 years_of_service NUMBER;
6 months_of_service NUMBER;
7 BEGIN
8 years_of_service := EXTRACT(YEAR FROM service_interval);
9 months_of_service := EXTRACT(MONTH FROM service_interval);
10 DBMS_OUTPUT.PUT_LINE(years_of_service || ' years and ' || months_of_service || ' months');
11 END;
12 /
PL/SQL procedure successfully completed.
SQL>
|