create or replace function ma_department(departId in number) return varchar2 is
union_mc varchar2(500);
begin
if departId>0 then
for cur in (select t.parent,t.name from department t where parent is not null start with t.id=departId connect by prior t.parent =t.id order by t.id asc) loop
if(length(union_mc)>500) then
RAISE_APPLICATION_ERROR(-20123,'return varchar length is too long',true);
end if;
if(union_mc is null) then
union_mc := cur.name;
else
union_mc :=union_mc||'/'||cur.name;
end if;
end loop;
end if;
return(union_mc);
end ma_department;