码迷,mamicode.com
首页 > 其他好文 > 详细

wm_cancat

时间:2018-09-13 13:59:55      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:dbi   CON_ID   select   name   return   elf   sele   in out   varchar   

select con_id,dbid,NAME,OPEN_MODE from v$pdbs; 
alter session set container=PDBORCL;
create or replace type type_concat authid current_user as object
(
  curr_str varchar2(32767),
  static function odciaggregateinitialize(sctx in out type_concat)
    return number,
  member function odciaggregateiterate(self in out type_concat,
                                       p1   in varchar2) return number,
  member function odciaggregateterminate(self        in type_concat,
                                         returnvalue out varchar2,
                                         flags       in number)
    return number,
  member function odciaggregatemerge(self  in out type_concat,
                                     sctx2 in type_concat) return number
)
;
/

create or replace type body type_concat is
  static function odciaggregateinitialize(sctx in out type_concat)
    return number is
  begin
    sctx := type_concat(null);
    return odciconst.success;
  end;
  member function odciaggregateiterate(self in out type_concat,
                                       p1   in varchar2) return number is
  begin
    if (curr_str is not null) then
      curr_str := curr_str || ‘,‘ || p1;
    else
      curr_str := p1;
    end if;
    return odciconst.success;
  end;
  member function odciaggregateterminate(self        in type_concat,
                                         returnvalue out varchar2,
                                         flags       in number) return number is
  begin
    returnvalue := curr_str;
    return odciconst.success;
  end;
  member function odciaggregatemerge(self  in out type_concat,
                                     sctx2 in type_concat) return number is
  begin
    if (sctx2.curr_str is not null) then
      self.curr_str := self.curr_str || ‘,‘ || sctx2.curr_str;
    end if;
    return odciconst.success;
  end;
end;
/

--函数: 
create or replace FUNCTION WM_CONCAT(P1 VARCHAR2) RETURN VARCHAR2 AGGREGATE USING type_concat;

  

wm_cancat

标签:dbi   CON_ID   select   name   return   elf   sele   in out   varchar   

原文地址:https://www.cnblogs.com/xsdf/p/9639567.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!