Question: rigger and Stored Procedure: 1 . Write Triggers that logs any changes on Salary column of Employee table. Trig _ Update _ Audit _ EmpSalary

rigger and Stored Procedure:
1. Write Triggers that logs any changes on Salary column of Employee table.
Trig_Update_Audit_EmpSalary to log any changes of salary by Update
Trig_Insert_Audit_EmpSalary to log any changes of salary by Insert
Trig_Delete_Audit_EmpSalary to log any changes of salary by Delete
1) Before creating any trigger for this lab, Alter Table to Drop all the PK, FK,
Unique Constraints, Cascade, Check options from the Tables Employee
and Department for this lab to avoid any possible conflict with a system
trigger or any table mutating problem.
Or you can create a new Employee table without any Constraints for Lab6.
3) Write (Create) Stored Procedure SP_Audit_ EmpSalary that inserts all the
history of the data of changes by Update, Insert, Delete on Salary of Employee
Table to Audit_EmpSalary table.
4) Call the Stored procedure SP_Audit_EmpSalary at the end of the body of
each Trigger to record all the history of the changes by Update/Insert/Delete.
2. Write Stored Procedure SP_Audit_ EmpSalary as follow. Whenever data for
the salary column in Employee table are updated, deleted, or inserted, both
the previous and new salary values are recorded in Audit_EmpSalary table to
allow tracing the history of changes.
1) On Update of the trigger, Insert the new record into a table named
Audit_EmpSalary as follow:
(date_of_change, DML_Type, old_SSN, new_SSN, old_Salary,
new_Salary, old_Dno, new_Dno)
2) On Delete of the trigger, Insert the deleted record into the table
Audit_EmpSalary as well. Since there is no new record for delete,
insert NULL for the new record columns.
3) On Insert of the trigger, Insert the newly inserted record into a table
named Audit_ EmpSalary as well. Since there is no old record for
Insert, insert NULL for the old record columns.
3. Let each Event happen to get each trigger you created fired by executing
the following DML on Employee table One at a time:
UPDATE EMPLOYEE with Salary to 99,000 for Employees of DNO =5
UPDATE Employee SET Salary =99000 WHERE Dno =5;
(Submit Update statement to change salary to 99,000 to activate your
Trig_Update_Audit_EmpSalary)
DELETE John Smith from EMPLOYEE
(Submit Delete statement to activate your Trig_Delete_Audit_EmpSalary)
INSERT EMPLOYEE with Your Info
(Submit Insert statement with your info to activate your
Trig_Insert_Audit_EmpSalary)
4. Show each trigger you create was fired correctly with Select statements on
affected columns and tables Before and After the Trigger is fired .
// You dont have to follow all the steps in this part 5 for testing unless you
need to. It is just suggestion .
5. Do not make all the DML events above in task 3 at once to fire all the
triggers. Make one event per a Trigger creation per one transaction to test to
avoid any possible concurrent table mutation problem. This means that your
script or a query execution sequence should look like in the following order:
Login //if needed -- optional
1. Create or replace Trigger_Update on Update
2. Select statement to show the original table before the Trigger_Update
fired
3. One Update statement to trigger(fire) the Trigger_Update
4. Select statement to show the tables affected by Trigger_Update
5. Drop Trigger_Update //optional
Logout //optional
Login //optional
1T. Create Trigger_Delete on Delete
2. Select statement to show the original table before the Trigger_Delete
fired
3. One Delete statement to trigger the Trigger_Delete
4. Select statement to show the table affected by Trigger_Delete
5. Drop Trigger_Delete //optional
Logout //optional
5. Submit Screenshots of each trigger creation, triggering event, and Select on
affected columns and tables to show that your triggers all get correctly fired
as well as the data inserted in Audit_ EmpSalary by the Stored Procedure
called at the end of each trigger.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!