`
Dead_knight
  • 浏览: 1194640 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
博客专栏
752c8642-b795-3fe6-946e-a4e845bffdec
Spring Securi...
浏览量:238432
33caa84e-18a6-3036-a82b-6e2106a4de63
clojure专题
浏览量:48163
E17ca077-44df-3816-a3fe-471c43f6e1e5
WebLogic11g
浏览量:236010
社区版块
存档分类
最新评论

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

SQL 
阅读更多
    当执行如下语句时出现“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进行读取
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics