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:
Write Triggers that logs any changes on Salary column of Employee table.
TrigUpdateAuditEmpSalary to log any changes of salary by Update
TrigInsertAuditEmpSalary to log any changes of salary by Insert
TrigDeleteAuditEmpSalary to log any changes of salary by Delete
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 Lab
Write Create Stored Procedure SPAudit EmpSalary that inserts all the
history of the data of changes by Update, Insert, Delete on Salary of Employee
Table to AuditEmpSalary table.
Call the Stored procedure SPAuditEmpSalary at the end of the body of
each Trigger to record all the history of the changes by UpdateInsertDelete
Write Stored Procedure SPAudit 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 AuditEmpSalary table to
allow tracing the history of changes.
On Update of the trigger, Insert the new record into a table named
AuditEmpSalary as follow:
dateofchange, DMLType, oldSSN newSSN oldSalary,
newSalary, oldDno, newDno
On Delete of the trigger, Insert the deleted record into the table
AuditEmpSalary as well. Since there is no new record for delete,
insert NULL for the new record columns.
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.
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 for Employees of DNO
UPDATE Employee SET Salary WHERE Dno ;
Submit Update statement to change salary to to activate your
TrigUpdateAuditEmpSalary
DELETE John Smith from EMPLOYEE
Submit Delete statement to activate your TrigDeleteAuditEmpSalary
INSERT EMPLOYEE with Your Info
Submit Insert statement with your info to activate your
TrigInsertAuditEmpSalary
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 for testing unless you
need to It is just suggestion
Do not make all the DML events above in task 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
Create or replace TriggerUpdate on Update
Select statement to show the original table before the TriggerUpdate
fired
One Update statement to triggerfire the TriggerUpdate
Select statement to show the tables affected by TriggerUpdate
Drop TriggerUpdate optional
Logout optional
Login optional
T Create TriggerDelete on Delete
Select statement to show the original table before the TriggerDelete
fired
One Delete statement to trigger the TriggerDelete
Select statement to show the table affected by TriggerDelete
Drop TriggerDelete optional
Logout optional
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
