我有一個觸發器在信用卡到期日過期時引發異常。無論我插入什麼日期,都會引發異常。有誰知道爲什麼會發生這種情況?無論條件如何,觸發器總是觸發
觸發:
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大,所以你的觸發器正在工作。 –