salix/db/routines/vn/triggers/receipt_beforeInsert.sql

18 lines
458 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`receipt_beforeInsert`
BEFORE INSERT ON `receipt`
FOR EACH ROW
BEGIN
DECLARE vIsAutoConciliated BOOLEAN;
IF NEW.isConciliate = FALSE THEN
SELECT isAutoConciliated INTO vIsAutoConciliated
FROM accounting a
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
WHERE a.id = NEW.bankFk;
SET NEW.isConciliate = vIsAutoConciliated;
END IF;
END$$
DELIMITER ;