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

Create a trigger to do the following: AFTER the value in the ‘REGION’ column of

ID: 3772342 • Letter: C

Question

Create a trigger to do the following:

AFTER the value in the ‘REGION’ column of the ‘SALES’ table is updated the trigger must add an audit record to the SALES_AUDIT table indicating that a SALES record update happened.

Create the SALES_AUDIT Table as follows

CREATE TABLE SALES_AUDIT (AUDIT_TIMESTAMP TIMESTAMP NOT NULL PRIMARY KEY);

Update 1 of the existing records in the SALES table to have a different value in the ‘REGION’ column.

I also need you issue the 2 commands:

SELECT * FROM SALES;

SELECT * FROM SALES_AUDIT;

after your create trigger, and run the update statement.

Explanation / Answer

CREATE OR REPLACE TRIGGER sales_audit
AFTER INSERT
ON sales
FOR EACH ROW

DECLARE
region varchar2(10);

BEGIN

SELECT * FROM sales_audit;
INSERT INTO sales
( order_id,
quantity,
cost_per_item,
total_cost,
username )
VALUES
( :new.order_id,
:new.quantity,
:new.cost_per_item,
:new.total_cost);

END;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote