我有一个触发器在信用卡到期日过期时引发异常。无论我插入什么日期,都会引发异常。有谁知道为什么会发生这种情况?无论条件如何,触发器总是触发
触发:
create or replace trigger card_expired
before insert or update on invoice
for each row
begin
if :new.exp_date >= sysdate
then
raise_application_error(-20000,'Card is expired');
end if;
end;
插入语句(EXP_DATE是19年12月31日):
insert into invoice(invoice_id, invoice_date, invoice_due, cc_type, cc_no,
exp_date, guest_id, reservation_id, admins_id)
values(invoice_sequence.nextval, sysdate, bill_due(100101), 'Visa',
'4838892900203328', to_date('12-31-2019','mm/dd/yyyy'), 110, 100101, 110);
您的插入中没有列列表。所以我们不知道你在哪里插入代码并且你的代码引入了错误。始终使用插入列表。如果你添加一个,你可能会发现你的意外行为消失 –
你的一年也没有一个世纪。 19 = 1919年还是2019年?如果你的代码没有歧义,你现在或将来都不太可能有错误或意外的行为。 –
2019-12-31肯定比SYSDATE大,所以你的触发器正在工作。 –