|
-
Actually, if you like that, what about ...
create or replace type AggratinateImpl as object
(
concat_string varchar2(4000),
static function ODCIAggregateInitialize(sctx in out AggratinateImpl) return number,
member function ODCIAggregateIterate(self in out AggratinateImpl, value in varchar2) return number,
member function ODCIAggregateTerminate(self in AggratinateImpl, returnValue out varchar2,flags in number) return number,
member function ODCIAggregateMerge(self in out AggratinateImpl,ctx2 in AggratinateImpl) return number
);
create or replace type body AggratinateImpl is
static function ODCIAggregateInitialize(sctx IN OUT AggratinateImpl)
return number is
begin
sctx := AggratinateImpl('');
return ODCIConst.Success;
end;
member function ODCIAggregateIterate(self IN OUT AggratinateImpl, value IN varchar2)
return number is
begin
self.concat_string := self.concat_string||value;
return ODCIConst.Success;
end;
member function ODCIAggregateTerminate(self IN AggratinateImpl, returnValue OUT
varchar2, flags IN number) return number is
begin
returnValue := self.concat_string;
return ODCIConst.Success;
end;
member function ODCIAggregateMerge(self in out AggratinateImpl,ctx2 in AggratinateImpl) return number
is
begin
self.concat_string := self.concat_string||ctx2.concat_string;
return ODCIConst.Success;
end;
end;
/
create or replace function Aggratinate(input varchar2) return varchar2
aggregate using AggratinateImpl;
... then, using the same my_table as before ...
select my_section,aggratinate(my_text)
from my_table group by my_section;
... or ...
select my_section,aggratinate(my_text)
from (select my_section,my_text from my_table order by my_piece desc)
group by my_section
/
you need the create type privilege,and might blow out the varchar2(4000), but hey, it's pretty elegant stuff though i say so myself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|