CREATE OR REPLACE FUNCTION ISRUNYEAR (INYEAR IN NUMBER) RETURN NUMBERIS V1 VARCHAR2 (20);BEGIN /*这是一个判断闰年的函数*/ IF (INYEAR NOT BETWEEN 999 AND 10000) THEN RETURN -1; END IF; SELECT SUBSTR (TO_CHAR (LAST_DAY(TO_DATE (TO_CHAR (INYEAR) || '0201', 'yyyymmdd')), 'yyyymmdd'),7,2) INTO V1 FROM DUAL; IF (TO_NUMBER (V1) = 29) THEN RETURN 0; ELSE RETURN 1; END IF;END;
示例:
select decode(isRunYear(200),0,'yes',1,'no',-1,'error') from dual