CREATE DEFINER=root
@%
FUNCTION get_org_Ids
(grpId longtext) RETURNS longtext CHARSET utf8
BEGIN
DECLARE str LONGTEXT;
DECLARE cid LONGTEXT;
SET SESSION group_concat_max_len = 102400;
SET str = ‘’;
SET cid = grpId;
WHILE cid IS NOT NULL DO
SET str = CONCAT(str, ‘,’ ,cid);
SELECT GROUP_CONCAT(id) INTO cid FROM jy_base_org WHERE FIND_IN_SET(pId, cid) > 0;
END WHILE;
SET str =SUBSTRING(str,2);
RETURN str;
END