Reputation: 555
I would like to update a column in another table with the code below but I get a error that the trigger is invalid. Whats wrong with it?
CREATE OR REPLACE TRIGGER UPDATE_PAYMENT
AFTER INSERT OR UPDATE ON PAYMENT
for each row
begin
update PAYMENTTYPE PT
set PT.PAYMENTTYPECOLUMN = PAYMENT.PAYMENTTYPECOLUMN
where PT.ID = :NEW.ID and PT.ID2 = :NEW.ID2;
end UPDATE_PAYMENT;
Upvotes: 1
Views: 55
Reputation: 22949
In your trigger you refer twice to PAYMENT
columns by :NEW.
, and this is correct, while the third time you use PAYMENT.
, which is wrong.
The trigger should be:
CREATE OR REPLACE TRIGGER UPDATE_PAYMENT
AFTER INSERT OR UPDATE ON PAYMENT
for each row
begin
update PAYMENTTYPE PT
set PT.PAYMENTTYPECOLUMN = :NEW.PAYMENTTYPECOLUMN -- <------ HERE
where PT.ID = :NEW.ID and PT.ID2 = :NEW.ID2;
end UPDATE_PAYMENT;
Upvotes: 2