簡易年資計算 SQL Stored ProcedureSET SERVEROUTPUT ON
DECLARE v_seniority VARCHAR2(1); --年資 v_career_start VARCHAR2(50) := '20120604'; --年資起日 BEGIN SELECT floor(months_between(sysdate , TO_DATE(v_career_start,'YYYYMMDD')) / 12) into v_seniority FROM dual; DBMS_OUTPUT.put_line('年資:' || v_seniority || '~' || (to_number(v_seniority) +1)); END; --年資:9~10