oracle迁移到12c的时 wm_concat 报错解决

原来的保存function

create or replace function get_area_path_name(areaId  in number) return varchar2 is
  pathName  varchar2(1000);
begin
  select replace(to_char(wm_concat(pathname) ),',','/') into pathName
  from (select rs.name as pathname
  from rs_area rs
  start with rs.id=areaId
  connect by  rs.id = prior rs.parent_id
  order by rs.area_type_id );
  return pathName;
exception
  when others then
    return '';

end get_area_path_name;

修改后:

create or replace function get_area_path_name(areaId in number)
  return varchar2 is
  pathName varchar2(1000);
begin
  select replace(to_char(LISTAGG(pathname, ',') within
                         group(order by pathname)),
                 ',',
                 '/')
    into pathName
    from (select rs.name as pathname
            from rs_area rs
           start with rs.id = areaId
          connect by rs.id = prior rs.parent_id
           order by rs.area_type_id);
  return pathName;
exception
  when others then
    return '';

end get_area_path_name;

猜你喜欢

转载自www.cnblogs.com/linhongwenBlog/p/10565790.html