DELIMITER //
CREATE TRIGGER invoices_after_insert
AFTER INSERT ON invoices
FOR EACH ROW
BEGIN
INSERT INTO invoices_audit VALUES
(NEW.vendor_id, NEW.invoice_number,
NEW.invoice_total, 'INSERTED', NOW());
END//
CREATE TRIGGER invoices_after_delete
AFTER DELETE ON invoices
FOR EACH ROW
BEGIN
INSERT INTO invoices_audit VALUES
(OLD.vendor_id, OLD.invoice_number,
OLD.invoice_total, 'DELETED', NOW());
END//
invoices_audit |
||
Field |
Type |
Null |
vendor_id |
INT |
NOT |
invoice_number |
VARCHAR |
NOT |
invoice_total |
DECIMAL |
NOT |
action_type |
VARCHAR |
NOT |
action_date |
DATETIME |
NOT |