You have the following table:
CREATE TABLE Emp_log (
Emp_id NUMBER
Log_date DATE,
New_salary NUMBER,
Action VARCHAR (20));
You have the following data in the EMPLOYEES table:
EMPLOYEE_ID LAST_NAME SALARY DEPARTMENT_ID
———– ——————- ———— ————- 100 Bill 24000 90
101 Kochhar 17000 90
102 De Haan 17000 90
103 Hunold 9000 60
104 Ernst 6000 60
105 Austin 4800 60
106 Pataballa 4800 60
107 Lorentz 4200 60
108 Greenberg 12000 100
201 Hartstein 13000 20
202 Fay 6000 20
You create this trigger:
CREATE OR REPLACE TRIGGER Log_salary_increase
AFTER UPDATE ON employees
FOR EACH ROW
WHEN (new.Salary > 1000)
BEGIN
INSERT INTO Emp_log (Emp_id, Log_date, New_Salary, Action) VALUES (:new.Employee_id, SYSDATE, :new.SALary, ‘NEW SAL’);
END
/
Then, you enter the following SQL statement:
UPDATE Employee SET Salary = Salary + 1000.0
Where Department_id = 20M
What are the result in the EMP_LOG table?
A.
EMP_ID LOG_DATE NEW_SALARY ACTION
———- ——– ———- ———-
201 24-SEP-02 13000 NEW SAL
202 24-SEP-02 600 NEW SAL
B.
EMP_ID LOG_DATE NEW_SALARY ACTION
———- ——– ———- ———-
201 24-SEP-02 14000 NEW SAL
202 24-SEP-02 7000 NEW SAL
C.
EMP_ID LOG_DATE NEW_SALARY ACTION
———- ——– ———- ———-
201 24-SEP-02 NEW SAL
202 24-SEP-02 NEW SAL
D.
No rows are inserted.
Explanation:
Employees with a Department Code = 20 are updated in the SQL Statement and 1000 is added to there existing salary.
Employee Hartstein has a salary of 1300 and Employee Fay has a salary of 6000 before the update.
The Trigger inserts a record for each row into the Emp_log table. The trigger specifies to insert the new value
of the salary therefore the Salary values inserted will be 14000 for Hartstein & 700 for Fay.
Answer A is incorrect the Trigger specifies to insert the new values. If the Trigger specified the: old.salary this would be correct
Answer C omits the value f the: new.Salary
Answer D is wrong. This trigger will fire and since it is a row-level trigger, it will insert a record into the Emp_log table for each record updated.
UPDATE Employee SET Salary = Salary + 1000.0
Where Department_id = 20M …
I had assumed that that answer would be D because as is, the above will cause an error because of the ‘M’ after the ’20’. Clearly, the answer assumes that it’s an error.
it’s a typo. the ‘M’ would cause an error and ‘no rows inserted’ will never be displayed. So it’s safe to assume that it’s a typo