SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE OR REPLACE TRIGGER TRIGGER_EMP_AUDIT AFTER UPDATE OF SALARY ON EMPLOYEES FOR EACH ROW DECLARE V_SALARIO_ANTERIOR EMPLOYEES.SALARY%TYPE:= 0; BEGIN SELECT SALARY INTO V_SALARIO_ANTERIOR FROM EMPLOYEES WHERE EMPLOYEE_ID = :NEW.EMPLOYEE_ID; IF :OLD.SALARY != :NEW.SALARY THEN INSERT INTO EMP_AUDIT (EMPLOYEE_ID, AUDIT_TIMESTAMP, AUDIT_MESSAGE) VALUES (:NEW.EMPLOYEE_ID, SYSTIMESTAMP, 'El salario anterior era : ' || V_SALARIO_ANTERIOR || ' ahora es : ' || :NEW.SALARY); END IF; END TRIGGER_EMP_AUDIT;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear