Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

there is some way to create a trigger and read values from same table ?

User_76ZA2May 16 2022 — edited May 16 2022

trigger is as following:
CREATE OR REPLACE TRIGGER PRODUCT_CATALOG_TRIGGER
AFTER UPDATE
ON COR_MERCADORIA
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
record_is_eligible NUMBER := 0;
BEGIN
SELECT COUNT(MERC_CODIGO) INTO record_is_eligible FROM COR_MERCADORIA CM
WHERE 1=1
AND CM.DFLT_OM_CODIGO IN('1','6')
AND CM.IS_ACTIVE = 1
AND CM.VENDOR IN('DELL', 'HP', 'IBM')
AND CM.MERC_CODIGO IN (:new.MERC_CODIGO);
IF record_is_eligible > 0 THEN
--some other expression ...
END IF;
END;
i must read some values from the same table to validate my items, but
i'm getting the error "trigger is mutating";
someone have some solution to help ?

Comments
Post Details
Added on May 16 2022
7 comments
10,483 views