14 lines
468 B
SQL
14 lines
468 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`awb_recibida_afterDelete`
|
|
AFTER DELETE ON `awb_recibida`
|
|
FOR EACH ROW
|
|
IF (SELECT COUNT(*) FROM recibida_iva where recibida_id = OLD.recibida_id) = 0
|
|
AND
|
|
(SELECT COUNT(*) FROM recibida_vencimiento where recibida_id = OLD.recibida_id) = 0
|
|
AND
|
|
(SELECT contabilizada FROM recibida WHERE id = OLD.recibida_id) = 0
|
|
THEN
|
|
DELETE FROM recibida WHERE id = OLD.recibida_id;
|
|
END IF$$
|
|
DELIMITER ;
|