我认为这个触发器的逻辑是正确的,当我向我的表中插入新的付款时,对付款的一些检查是针对入库的到期日 - 然后它将设置付款状态
/* Handle the users payment status automatically on insert */
-- Has the user paid on time?
IF:NEW.payment_received <= :NEW.payment_due THEN
:NEW.payment_status := 'PAID';
END IF;
-- Has the user paid late?
IF:NEW.payment_received > :NEW.payment_due THEN
:NEW.payment_status := 'PAID LATE';
END IF;
-- Is the payment pending?
IF :NEW.payment_due > SYSDATE AND :NEW.payment_received IS NULL THEN
:NEW.payment_status := 'PENDING';
END IF;
-- Is the payment overdue?
IF :NEW.payment_due < SYSDATE AND :NEW.payment_received IS NULL THEN
:NEW.payment_status := 'OVERDUE';
END IF;
-- A future payment cannot of been received, set to current date
IF :NEW.payment_received > SYSDATE THEN
:NEW.payment_received := SYSDATE;
END IF;
该代码适用于除PENDING
和OVERDUE
之外的所有方案。我只输入一些虚拟数据,我将:NEW.payment_due
设置为28-APR-2014,将NULL
设置为:NEW.payment_received;
,系统将其值设置为OVERDUE
,这不应该&如果日期还没有过去,我可能会错过一些东西吗?
提前致谢 - 亚历克斯。