Create a trigger called SALARY_CHANGE_UPD. It is an AFTER UPDATE TRIGGER on the
ID: 3772327 • Letter: C
Question
Create a trigger called SALARY_CHANGE_UPD.
It is an AFTER UPDATE TRIGGER on the SALARY COLUMN OF THE EMPLOYEE TABLE. Compare the OLD salary record with the NEW record to check whether they are different. If they are INSERT a record into the following table, which you will have to create :
CREATE TABLE SALARY_CHANGES(EMPNO NUMBER, NEW_SALARY DECIMAL (10,2), OLD_SALARY DECIMAL(10,2), TIMESTMP DATE);
NOTE : You will need to specify REFERENCE NEW ROW AS NR and REFERENCING OLD ROW AS OR to be able to access the records
Explanation / Answer
CREATE TRIGGER SALARY_CHANGE_UPD FOR Employee
AFTER UPDATE AS
BEGIN
IF (Old.salary <> New.salary) THEN
INSERT INTO SALARY_CHANGES
(EMPNO,NEW_SALARY,OLD_SALARY,TIMESTMP)
VALUES (
OLD.EMPNO,
'NEW.NR',
OLD.OR, 'NOW',USER);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.