I have an Oracle, apex application with a MasterDetail Form. I need to do a BeforeInsert Trigger for the details part of the form. I need to populate the fields for the BEFOREINSERT_CHARGES with the data from another table (AHAR_PARTSLABOR) This is what I have so far yet it keeps giving me a message error:
ORA-04082: NEW or OLD references not allowed in table level triggers.
CREATE OR REPLACE Trigger BEFOREINSERT_CHARGES
BEFORE INSERT
On AHAR_REPAIRORDER_CHARGES
--DECLARAR VARIABLES
--T_CHARGES_TYPE IN CHAR(11);
--T_CHARGES_PRICE IN NUMBER;
--T_CHARGES_DISCOUNT IN NUMBER;
--VALIDAR QUE EL CHAR_CODE INGRESADO POR EL USUARIO EXISTA
BEGIN
--SELECT PARA PASAR LOS VALORES DE PARTSLABOR A CHARGES
SELECT (PARTLABOR_TYPE, PARTLABOR_PRICE, PARTLABOR_DISCOUNT)
INTO (:NEW.CHARGES_TYPE, :NEW.CHARGES_PRICE, :NEW.HARGES_DISCOUNT)
FROM AHAR_PARTSLABOR
WHERE :NEW.CHARGE_CODE = PARTLABOR_ID;
END;
In order to be able to change the
:newvalues you have to use a "for each row" trigger: