Create a trigger for the Invoices table that automatically i

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

Solution

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;

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site