oracle数据库转mysql-04

select *from t_com_dept_info;
select *from t_com_dept_info where find_in_set(dept_id, getChildLst_DEPT('DEP33603856-a4df-48e2-8eef-ef255ba80417'));

 

CREATE DEFINER=`gk`@`%` FUNCTION `getChildLst_Org`(
`rootId` VARCHAR(4000)
) RETURNS varchar(4000) CHARSET utf8mb4
BEGIN

DECLARE sTemp VARCHAR(4000);
DECLARE sTempChd VARCHAR(4000);

SET sTempChd = '';
if rootId is null or rootId = '' then set sTempChd = '-';
else set sTempChd = rootId;
end if;

SET sTemp = '';
SET sTemp = concat(sTemp,',',sTempChd);
WHILE sTempChd is not null DO

SET sTemp = concat(sTemp,',',sTempChd);
SELECT GROUP_CONCAT(t.organ_id) INTO sTempChd FROM t_com_organ_info t where FIND_IN_SET(nvl(t.parent_id,'-'),sTempChd)>0;

END WHILE;

RETURN sTemp;

END

posted @ 2021-10-25 16:59  hncszz  阅读(31)  评论(0编辑  收藏  举报