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

16 lines
479 B
MySQL
Raw Normal View History

2024-01-30 06:48:29 +00:00
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`awbInvoiceIn_afterDelete`
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 ;