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;