使用oracle数据库的函数方法
create or replace function f_get_parentdeptname
(in_deptid in number)
return varchar2 is
v_name varchar2(200);
begin
begin
select replace(to_char(wm_concat(departmentname)),',','/') into v_name from (
select m.id,s.subcompanyname||'/'||m.departmentname departmentname,m.supdepid ,s.subcompanyname
from
(select id,departmentname,supdepid,m.subcompanyid1 from hrmdepartment m
where m.id=in_deptid
order by supdepid) m
left join
hrmsubcompany s
on m.subcompanyid1 = s.id
);
exception when others then
v_name:='';
end;
if v_name is null then
return '';
end if;
return v_name;
end ;
直接调用f_get_parentdeptname()函数方法
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/e1c3fc2552404fd0fbef016d7faa2996.png)