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

16 lines
477 B
MySQL
Raw Normal View History

2024-01-30 06:48:29 +00:00
DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`awbInvoiceIn_afterDelete`
2024-01-30 06:48:29 +00:00
AFTER DELETE ON `awbInvoiceIn`
FOR EACH ROW
BEGIN
2024-02-01 06:08:25 +00:00
IF (NOT(SELECT COUNT(*) FROM invoiceInTax where invoiceInFk = OLD.invoiceInFk))
2024-01-30 06:48:29 +00:00
AND
2024-02-01 06:08:25 +00:00
(NOT(SELECT COUNT(*) FROM invoiceInDueDay where invoiceInFk = OLD.invoiceInFk))
2024-01-30 06:48:29 +00:00
AND
2024-02-01 06:08:25 +00:00
(NOT(SELECT isBooked FROM invoiceIn WHERE id = OLD.invoiceInFk) )
2024-01-30 06:48:29 +00:00
THEN
DELETE FROM invoiceIn WHERE id = OLD.invoiceInFk;
END IF;
END$$
DELIMITER ;