CREATE TRIGGER barcode1 BEFORE INSERT ON employeepc
FOR EACH ROW
BEGIN
IF NEW.Barcode IS NULL THEN
SET NEW.REMAINING := NEW.employeeid;
END IF;
END;
答案 0 :(得分:0)
DELIMITER $$
CREATE TRIGGER before_employee_update
BEFORE UPDATE ON employees
FOR EACH ROW
BEGIN
INSERT INTO employees_audit
SET action = 'update',
employeeNumber = OLD.employeeNumber,
lastname = OLD.lastname,
changedat = NOW();
END$$
DELIMITER ;