Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please some help: Notice: before working on these problems, please execute the c

ID: 3687575 • Letter: P

Question

Please some help:

Notice: before working on these problems, please

execute the command

set serveroutput on;

Execute the script files companyDB.sql each time before you start to work on a problem (not a sub-problem).

1. Update trigger

a. Write a trigger that fires when an employee’s salary is updated. The trigger will write a record into a table called SalUpdates. The record should contain the information of SSN, new salary, old salary, and date when the change is made. (Hint: You need create the table SalUpdates first)

b. Test the above trigger by updating the salary of employee with ssn=123456789 to 40000. List the tables employee and SalUpdates to verify the results are correct.

2. Delete Trigger: Write a trigger that fires when a command tries to delete some rows from DEPARTMENT table. The trigger will reject the deletion and display the warning information “failed operation” to the user. (Tip: use the system function raise_application_error).

Explanation / Answer

1.CREATE TRIGGER salary_ypdate AFTER UPDATE ON SalUpdates FOR EACH ROW WHEN (new.sal > 1000) BEGIN INSERT INTO SalUpdates VALUES (“ssn”,”newsalary”,”oldsalary”,”date”); END; To perform this trigger we will use UPDATE SalUpdates SET sal = sal + 1000.0 WHERE ssn>=123456789 AND ssn