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

Create a trigger for the Invoices table that automatically inserts the vendor na

ID: 3938820 • Letter: C

Question

Create a trigger for the Invoices table that automatically inserts the vendor name and address for a paid invoice into a table named ShippingLabels. The trigger should fire any time the PaymentTotal column of the Invoices table is updated. The structure of the ShippingLabels table is as follows:

CREATE TABLE ShipplingLabels (

VendorName varchar(50), VendorAddress1 varchar(50), VendorAddress2 varcha(50), VendorCity varchar(50), VendorState varchar(2), VendorZipcode Varchar(20) )

Use the UPDATE statement to test the trigger: UPDATE Invoices SET PaymentTotal = 67.92, PaymentDate = ‘2008-08-23’ WHERE InvoiceID = 100

Explanation / Answer

CREATE OR REPLACE TRIGGER AFTER_UPDATE_PAYMENTTOTAL
AFTER UPDATE of paymentTotal ON Invoices
FOR EACH ROW

BEGIN

INSERT INTO ShipplingLabels VALUES
('VendorName','VendorAddress1','VendorAddress1','City','State','Zipcode');

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