DROP	FUNCTION IF EXISTS	fn_is_rule_exists;
CREATE FUNCTION	fn_is_rule_exists(a_ruleID int,
								a_MapLvl	varchar(50),
								a_mapID 	int)
RETURNS INT
DETERMINISTIC
BEGIN
	DECLARE v_count INT;
	SELECT	COUNT(rm.id)
	INTO	v_count
	FROM	rule_master rm, rule_logics rl
	WHERE	rm.id = rl.rule_id
	AND		rm.id = a_ruleID
	AND		map_lvl = a_MapLvl
	AND 	map_id = a_mapID;
	RETURN	(v_count);
END;
