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

I need help with this assignment! PL/SQL Assignment 4 Notice: before working on

ID: 3712820 • Letter: I

Question

I need help with this assignment!

PL/SQL Assignment 4 Notice: before working on these problems, please execute the command set serveroutput on: each time before you start to work on a problem (not a Execute the script files company DB. sql sub-problem) · 1 Update trigger a Write a trigger that fires when an employee's salary is pdated 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 Salüpdates to verily the results are correc tables employee and Write a trigger that fires when a command tries to delete some rows from Delete DEPARTMEN: table The trigger will reject the deletion and display the warning information "Eailed operation" to the user. (Tip use the system function a ise application error 2. Trigger:

Explanation / Answer

Question 1)

For the given problem first the table sqlUpdates has to be created. Once the table is created trigger will be performed. For creatting salUpdates table I am assuming field and data type of the tables based on given information.

SQL statement to create salUpdates table-

CREATE TABLE salUpdates

(

SSN VARCHAR(20),

new_salary DECIMAL(6,2),

old_salary DECIMAL(6,2),

upDate DATE,

PRIMARY KEY (SSN)

);

a) // Trigger that will be issued when a salary is updated in employee table.

CREATE TRIGGER update_sal

AFTER UPDATE

OF salary

ON employee

FOR EACH ROW

DECLARE

empNo VARCHAR(20);

BEGIN

SELECT * FROM employee WHERE SSN = empNo;

INSERT INTO salUpdates (SSN, new_salary, old_salary, upDate) VALUES (:NEW.SSN, :NEW.salary, :OLD.salary, sysdate);

END;

b) // Updating salary to test the trigger.

UPDATE TABLE employee

SET salary = 40000

WHERE SSN = '123456789';