数据库
首页 > 数据库> > oracle数据库转mysql-04

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

标签:rootId,SET,sTempChd,04,4000,set,sTemp,mysql,oracle
来源: https://www.cnblogs.com/hncszz/p/15437522.html