DROP FUNCTION IF EXISTS `GET_NAVER_ESCODE`;;
CREATE DEFINER=`root`@`%` FUNCTION `GET_NAVER_ESCODE`(
	`V_CODE` VARCHAR(50)
)
RETURNS text CHARSET utf8mb4
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
	DECLARE RETURN_VALUE TEXT;
	
	BEGIN
		   
	SELECT concat(ID,'|', SHOPCATE) into RETURN_VALUE 
	 FROM CATEGORY
		WHERE 
	 JSON_EXTRACT(SHOPCATE, '$[5].cid') = V_CODE  AND LEVEL > 2 limit 1;
		   
	END;
 	SET RETURN_VALUE = IFNULL(RETURN_VALUE, '');
   RETURN (RETURN_VALUE);
END;;