本文主要是介绍oracle 行转列数据量太大报错,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
wmsys.wm_concat 这个函数存在缺陷,数据量大的时候,容易报ora-22813
没办法只能通过重新定义一个行转列函数,copy了一下 http://www.savedba.com/?p=955 这个人写的函数
有点问题,自己又改了下。
drop type t_dj_concat;
drop function dj_concat;
create or replace type t_dj_concat as object
(
curr_str clob,
static function odciaggregateinitialize(sctx in out t_dj_concat)
return number,
member function odciaggregateiterate(self in out t_dj_concat,
p1 in varchar2) return number,
member function odciaggregateterminate(self in t_dj_concat,
returnvalue out clob,
flags in number)
return number,
member function odciaggregatemerge(self in out t_dj_concat,
sctx2 in t_dj_concat) return number
);
/
create or replace type body t_dj_concat
is
static function odciaggregateinitialize(sctx in out t_dj_concat)
return number
is
begin
sctx := t_dj_concat(null) ;
return odciconst.success;
end;
member function odciaggregateiterate(self in out t_dj_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 t_dj_concat,
returnvalue out clob,
flags in number)
return number
is
begin
returnvalue := curr_str ;
return odciconst.success;
end;
member function odciaggregatemerge(self in out t_dj_concat,
sctx2 in t_dj_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 dj_concat(p1 varchar2)
return clob aggregate using t_dj_concat ;
/
然后测试完美解决
sb.append(" select rptcode,infcode,rowcode,colcode,nullable,infname,dj_concat(infvalue) as infvalue from CCISDIC group ");
sb.append(" by rptcode,infcode,rowcode,colcode,nullable,infname ");
return this.getJdbcService().findForList(sb.toString(),new Object[]{});
String value=map.get("infvalue").toString();
这篇关于oracle 行转列数据量太大报错的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!