DROP TRIGGER IF EXISTS trigger_before_insert_purchase_bad_debt;
CREATE TRIGGER trigger_before_insert_purchase_bad_debt
BEFORE INSERT ON comp_purchase_bad_debt
FOR EACH ROW SET NEW.serialNo = (SELECT nextSerialNo FROM view_serial_comp_purchase_bad_debt WHERE companyID = NEW.companyID);