create or replace type string_sum_obj as object (
--聚合函式的實質就是乙個物件
sum_string varchar2(4000),
static function odciaggregateinitialize(v_self in out string_sum_obj) return number,
--物件初始化
member function odciaggregateiterate(self in out string_sum_obj, value in varchar2) return number,
--聚合函式的迭代方法(這是最重要的方法)
member function odciaggregatemerge(self in out string_sum_obj, v_next in string_sum_obj) return number,
--當查詢語句並行執行時,才會使用該方法,可將多個並行執行的查詢結果聚合
member function odciaggregateterminate(self in string_sum_obj, return_value out varchar2 ,v_flags in number) return number
--終止聚集函式的處理,返回聚集函式處理的結果.)/
create or replace type body string_sum_obj is
static function odciaggregateinitialize(v_self in out string_sum_obj) return number is
begin
v_self := string_sum_obj(null);
return odciconst.success;
end;
member function odciaggregateiterate(self in out string_sum_obj, value in varchar2) return number is
begin
/* 連線 */
self.sum_string := self.sum_string || value;
return odciconst.success;
/* 最大值 */
if self.sum_stringvalue then
self.sum_string:=value;
end if;
return odciconst.success;
end;
member function odciaggregatemerge(self in out string_sum_obj, v_next in string_sum_obj) return number is
begin
/* 連線 */
self.sum_string := self.sum_string || v_next.sum_string;
return odciconst.success;
/* 最大值 */
if self.sum_stringv_next.sum_string then
self.sum_string:=v_next.sum_string;
end if;
return odciconst.success;
end;
member function odciaggregateterminate(self in string_sum_obj, return_value out varchar2 ,v_flags in number) return number is
begin
return_value:= self.sum_string;
return odciconst.success;
end;
end;
/create or replace function connstrsum(value varchar2) return varchar2
parallel_enable aggregate using string_sum_obj;
oracle 自定義 group 聚合函式
create or replace type clob group obj as object sum string clob,static function odciaggregateinitialize v self in out clob group obj return number,mem...
自定義聚合函式
新建database project 新建concatenate class using system using system.data using microsoft.sqlserver.server using system.data.sqltypes using system.io usin...
自定義聚合函式
create or replace type string sum obj as object 聚合函式的實質就是乙個物件 sum string varchar2 4000 static function odciaggregateinitialize v self in out string su...