Question
INSTRUCTION Using and Managing Triggers For the exercise below, you must create the Employee/Department database (script provided in the link ). drive.google.com/file/d/1TctakGU5SLQTDRRxX0HFGP9-flFK9ynj/view?usp=sharing You need to
INSTRUCTION Using and Managing Triggers
For the exercise below, you must create the Employee/Department database (script provided in the link ).
drive.google.com/file/d/1TctakGU5SLQTDRRxX0HFGP9-flFK9ynj/view?usp=sharing
You need to keep track of the information every time when a new employee is inserted in to the EMPLOYEES table. You want to accomplish this by using a DML trigger and creating an audit record into a new table called AUDIT_TABLE.
a. Create the AUDIT_TABLE by executing the following SQL statement. CREATE TABLE audit_table (action VARCHAR2(50), user_name VARCHAR2(30) DEFAULT user ||'-AA', (Use your own initials instead of AA here) last_change_date TIMESTAMP DEFAULT SYSTIMESTAMP);
b. Create a statement-level trigger called emp_audit_trg that inserts a row into the AUDIT_TABLE immediately after one or more rows are added to the EMPLOYEES table. The AUDIT_TABLE row should contain value Inserting in the action column. The other two columns should have their default values. Save your trigger code for later.
c. Test your trigger by inserting a row into EMPLOYEES. Use your first and last name as employees first and last name.
d. Use SELECT statement to query the AUDIT_TABLE to see that it contains the new row.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started