I've written a Trigger that only allows an update to a products price if it is at least 10% above cost. It appears to be working when I update one products price, however I need it to be able to update multiple products at once. Any suggestions? Thanks to anyone who can help.
create or replace TRIGGER P_check
BEFORE UPDATE ON ProductCat
FOR EACH ROW
BEGIN
IF (:new.ListPrice < :old.TotalCost * 1.1) THEN
raise_application_error (-20500, :new.ListPrice || ' is too low so the price stays ' ||:old.ListPrice);
ELSE
dbms_output.put_line ('Price was updated and the new price is ' || :new.ListPrice);
END IF;
END;
It should work fine. You have the trigger defined as FOR EACH ROW
; thus, your trigger will be invoked for each row changed in ProductCat
.
Share and enjoy.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.