ORA-06502: PL/SQL: numeric or value error错误解决

当执行如下语句时出现“06502数字或值错误”,func_fa_getunororgpath函数主要是将人员组织ID参数转换为人员名称、组织PATH。

select func_fa_getunororgpath(pc.personorgselect) from tbl_pt_createtask pc where pc.orderid='2-090210-008-096'


查看函数得知该函数返回VARCHAR2(4000)类型,函数代码如下:

create or replace function func_fa_getUNorOrgPath(idOrPath in varchar2) return string is
Result varchar2(4000);
urserOrOrgId varchar2(2000);
begin
urserOrOrgId:=idOrPath;
while urserOrOrgId is not null loop
…… ……
…… ……
if tmpStr is null then
Result:=Result ||tmpId ||';';
else
Result:=Result ||tmpStr ||';';
end if;
end loop;
return(substr(Result,0,length(Result)-1));
end func_fa_getUNorOrgPath;

当Result长度超过4000时,再执行Result:=Result ||tmpStr ||';';时即出现该错误,固改为返回CLOB类型,代码如下:

create or replace function func_fa_getUNorOrgPath(idOrPath in varchar2) return CLOB is
Result CLOB;
urserOrOrgId varchar2(2000);
urserOrOrgId:=idOrPath;
begin
if idOrPath is null then
return empty_clob();
end if;
DBMS_LOB.CREATETEMPORARY(Result, TRUE);
while urserOrOrgId is not null loop
…… ……
if tmpStr is null then
DBMS_LOB.writeappend(Result,LENGTH(tmpId),tmpId);
DBMS_LOB.writeappend(Result,LENGTH(';'),';');
else
DBMS_LOB.writeappend(Result,LENGTH(tmpStr),tmpStr);
DBMS_LOB.writeappend(Result,LENGTH(';'),';');
end if;
end loop;
return(substr(Result,0,length(Result)-1));
end func_fa_getUNorOrgPath;


但在java中读取数据时需要采用Stream进行读取
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值