我有两张桌子:
评估与评估_公告
CREATE TABLE "ASSESSMENT"
( "ASSESSMENT_NAME" VARCHAR2(50) NOT NULL ENABLE,
"DEADLINE_DATE" DATE NOT NULL ENABLE,
CONSTRAINT "ASSESSMENT_PK" PRIMARY KEY ("ASSESSMENT_NAME") ENABLE
)
CREATE TABLE "ASSESSMENT_ANNOUNCEMENT"
( "ASSESSMENT_NAME" VARCHAR2(50) NOT NULL ENABLE,
"DEADLINE_DATE" DATE NOT NULL ENABLE,
"ATTENTION" VARCHAR2(500) NOT NULL ENABLE,
CONSTRAINT "ASSESSMENT_ANNOUNCEMENT_PK" PRIMARY KEY ("ASSESSMENT_NAME") ENABLE
)
我正在考虑实现一个触发器,当 ASSESSMENT 表的 DEADLINE_DATE 列中的日期在 7 天内时更新到 'ASSESSMENT_ANNOUNCEMENT' 表。数据可能已经存储了 14 天,但是当它在截止日期的 7 天内 - 它会触发。除非插入日期在截止日期的 7 天内,否则不应在插入时触发。
到目前为止,我有以下代码:
CREATE OR REPLACE TRIGGER "TEST"
AFTER INSERT ON ASSESSMENT
FOR EACH ROW
BEGIN
insert into ASSESSMENT_ANNOUNCEMENT(ASSESSMENT_NAME, DEADLINE_DATE, ATTENTION)
values (:new.ASSESSMENT_NAME, :new.DEADLINE_DATE, 'DEADLINE IS 7 DAYS OR LESS');
WHERE DEADLINE_DATE >= (SYSDATE) - 7
任何帮助和指导将不胜感激!
谢谢!