wm_concat 根据它写一个自定义符号的分割函数

create or replace type MyConcatImpl as object  
(  
  str VARCHAR2(32767), -- second highest value seen so far  
  static function ODCIAggregateInitialize(sctx IN OUT MyConcatImpl)   
    return number,  
  member function ODCIAggregateIterate(self IN OUT MyConcatImpl,   
    value IN VARCHAR2) return number,  
  member function ODCIAggregateTerminate(self IN MyConcatImpl,   
    returnValue OUT VARCHAR2, flags IN number) return number,  
  member function ODCIAggregateMerge(self IN OUT MyConcatImpl,   
    ctx2 IN MyConcatImpl) return number  
);  
/  
  
create or replace type body MyConcatImpl is   
static function ODCIAggregateInitialize(sctx IN OUT MyConcatImpl)   
return number is   
begin  
  sctx := MyConcatImpl(NULL);  
  return ODCIConst.Success;  
end;  
  
member function ODCIAggregateIterate(self IN OUT MyConcatImpl, value IN VARCHAR2) return number is  
begin  
  if self.str is not null then  
    self.str := self.str || '、' || value;  
  else  
    self.str := value;  
  end if;  
  return ODCIConst.Success;  
end;  
  
member function ODCIAggregateTerminate(self IN MyConcatImpl, returnValue OUT VARCHAR2, flags IN number) return number is  
begin  
  returnValue := self.str;  
  return ODCIConst.Success;  
end;  
  
member function ODCIAggregateMerge(self IN OUT MyConcatImpl, ctx2 IN MyConcatImpl) return number is  
begin  
  if ctx2.str is not null then  
    self.str := self.str || '、' || ctx2.str;  
  end if;  
  return ODCIConst.Success;  
end;  
end;  
/  
create or replace FUNCTION MyConcat(input VARCHAR2) RETURN VARCHAR2   
PARALLEL_ENABLE AGGREGATE USING MyConcatImpl;

效果

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值