16 lines
475 B
MySQL
16 lines
475 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`awbInvoiceIn_afterDelete`
|
||
|
AFTER DELETE ON `awbInvoiceIn`
|
||
|
FOR EACH ROW
|
||
|
BEGIN
|
||
|
IF (SELECT COUNT(*) FROM invoiceInTax where invoiceInFk = OLD.invoiceInFk) = 0
|
||
|
AND
|
||
|
(SELECT COUNT(*) FROM invoiceInDueDay where invoiceInFk = OLD.invoiceInFk) = 0
|
||
|
AND
|
||
|
(SELECT isBooked FROM invoiceIn WHERE id = OLD.invoiceInFk) = 0
|
||
|
THEN
|
||
|
DELETE FROM invoiceIn WHERE id = OLD.invoiceInFk;
|
||
|
END IF;
|
||
|
END$$
|
||
|
DELIMITER ;
|