DROP TRIGGER IF EXISTS testTrigger;
CREATE TRIGGER testTrigger
BEFORE INSERT ON tbl_table1
FOR EACH ROW
BEGIN
INSERT INTO tbl_table2 VALUES (NEW.id,NEW.name);
END;
delimiter //
CREATE TRIGGER removeforeing
BEFORE DELETE ON products
FOR EACH ROW BEGIN
DELETE FROM sales_details WHERE product_code = OLD.product_code;
END//
delimiter ;
CREATE TRIGGER `before_delete` BEFORE DELETE ON `barcode_master`
FOR EACH ROW BEGIN
UPDATE library_emp_master SET job_type = 1 WHERE barcode_no = OLD.barcode_no;
END;
delimiter $$
CREATE TRIGGER copy_pid AFTER INSERT on upload FOR EACH ROW
BEGIN
INSERT INTO rating (uid,pid) VALUES (NEW.username,NEW.id);
END$$
delimiter ;
CREATE TRIGGER after_update
AFTER UPDATE ON hodm
FOR EACH ROW
INSERT INTO hodm_log
SET log_action = 'update',
user_name = NEW.user_name,
log_timestamp = NOW();