USE `lego`;

DROP PROCEDURE IF EXISTS del_synack_np_filter_rule;
DELIMITER //
CREATE PROCEDURE del_synack_np_filter_rule()
BEGIN

	IF EXISTS(SELECT * FROM t_vsm_np_filter WHERE filter_name = 'SYN_ACK_Attack')
	THEN
	DELETE FROM t_vsm_np_filter_device WHERE filter_id=(SELECT pkid FROM t_vsm_np_filter WHERE filter_name='SYN_ACK_Attack');
	DELETE FROM t_vsm_np_filter_device_status WHERE filter_id=(SELECT pkid FROM t_vsm_np_filter WHERE filter_name='SYN_ACK_Attack');
	DELETE FROM t_vsm_np_filter_rule WHERE filter_id=(SELECT pkid FROM t_vsm_np_filter WHERE filter_name='SYN_ACK_Attack');
	DELETE FROM t_vsm_np_filter WHERE filter_name = 'SYN_ACK_Attack';
END IF; 
END;
//
DELIMITER ;
CALL del_synack_np_filter_rule();

DROP PROCEDURE IF EXISTS del_synack_np_filter_rule;