View the step-by-step solution to:

Develop two database triggers that will update the employee audit table and employee deduction audit table when rows are either changed or deleted.

  • Develop two database triggers that will update the employee audit table and employee deduction audit table when rows are either changed or deleted. Use a sequence number to assign a unique identifier to each row as it is created in the audit table. Capture the user ID, date of the change or delete, and action (update or delete), plus all the fields in the before image of the row (e.g. before it is changed or deleted).


 

                       CREATE TABLE emp_audit  (

                             audit_uid              NUMBER(15),

                            change_date         DATE,

                            change_user         VARCHAR2(30),

                              action                  CHAR(1),

                              empno                 NUMBER(4),

                            ename                 VARCHAR2(10),

      job                       VARCHAR2(9),

      mgr                      NUMBER(4),

      hiredate               DATE,

      sal                        NUMBER(7,2),

     comm                   NUMBER(7,2),

    deptno                   NUMBER(2));


CREATE TABLE emp_deductions_audit   (

                             audit_uid                        NUMBER(15),

                            change_date                    DATE,

                            change_user                    VARCHAR2(30),

                              action                             CHAR(1),

                              fk_deduction                  VARCHAR2(30),

                             fk_empno                       NUMBER(4),

                             before_or_after_flag      CHAR(1),

                             deduction_amount          NUMBER(6,2));

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question