我正在尝试编写一个 BeforeReport 触发器,用于检查用户是否在创建后 120 秒内访问报告数据。
我的代码如下:
function BeforeReport return boolean is
ENTRYDATE TIMESTAMP;
SERVERDATE TIMESTAMP;
DIFFSECONDS NUMBER;
begin
/*Checks to see if user is accessing the data within 120 seconds of creation in database*/
VALIDTIMELENGTH := 120;
SELECT SYS_DATE INTO ENTRYDATE FROM WOS_REPORT_PARAM WHERE SEQUENCE_NUM=UPPER(:SEQUENCENUM) AND PARAMETER='year';
SERVERDATE := CURRENT_TIMESTAMP;
DIFFSECONDS := ((EXTRACT(YEAR FROM ENTRYDATE)- EXTRACT(YEAR FROM SERVERDATE))*31536000) +
((EXTRACT(MONTH FROM ENTRYDATE)- EXTRACT(MONTH FROM SERVERDATE))*2592000) +
((EXTRACT(DAY FROM ENTRYDATE) - EXTRACT(DAY FROM SERVERDATE))*86400) +
((EXTRACT(HOUR FROM ENTRYDATE) - EXTRACT(HOUR FROM SERVERDATE))*3600) +
((EXTRACT(MINUTE FROM ENTRYDATE) - EXTRACT(MINUTE FROM SERVERDATE))*60) +
(EXTRACT(SECOND FROM ENTRYDATE) - EXTRACT(SECOND FROM SERVERDATE));
IF DIFFSECONDS > VALIDTIMELENGTH THEN RETURN(FALSE);
ELSE
return (TRUE);
END IF;
END;
问题是,无论过去了多少时间,我的代码似乎都会返回 true。我没有正确实现我的秒/分钟代码吗?奇怪的是,我尝试同时返回(FALSE),但它仍然继续通过报告!甲骨文报告如此不一致,令人愤怒。非常感谢任何回应。