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