0

挿入または更新操作を確実に実行するときに、このトリガーに問題があります。ただし、トリガーはエラーなしで作成されます。目的は、invoice_total が payment_total + credit_total の合計よりも大きいかどうかを確認することです。どんな助けでも大歓迎です:

Create or Replace Trigger invoices_before_update_payment
Before Insert or Update On invoices
For Each Row
Declare
InvTotal Number;
t_payment Number;
t_credit Number;
Begin
select invoice_total, payment_total, credit_total
Into
InvTotal, t_payment, t_credit
From invoices
Where invoice_id = :New.invoice_id;
DBMS_OUTPUT.PUT_LINE(InvTotal);
If (InvTotal) < (t_payment + t_credit)
Then
Raise_application_error(-20005, 'Invoice total is larger than the credit total and payment total');
End if;
End;
/
4

1 に答える 1

1

トリガーが起動しているテーブルから選択することはできません。そうしないと、このエラーが発生します。

トリガーで単に :new 値を使用しないのはなぜですか?

BEGIN
IF :new.invoice_total > :new.payment_total + :new.credit_total THEN

エラー メッセージのセマンティクスに基づいて、関係演算子を逆にしました。

于 2013-09-26T23:58:56.017 に答える