• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
黄洪波写点东西的地方
博客园    首页    新随笔    联系   管理    订阅  订阅
使用CLOB抛出数字或值错误异常

 

今天在调试某个问题的时候,由于使用了很多循环,我需要都打印出来,试图使用clob整体处理之后再打印。

 

最后抛出此异常:数字或值错误。

网友解释如下:

$ oerr ora 6502
06502, 00000, "PL/SQL: numeric or value error%s"
// *Cause: An arithmetic, numeric, string, conversion, or constraint error
// occurred. For example, this error occurs if an attempt is made to
// assign the value NULL to a variable declared NOT NULL, or if an
// attempt is made to assign an integer larger than 99 to a variable
// declared NUMBER(2).
// *Action: Change the data, how it is manipulated, or how it is declared so
// that values do not violate constraints.
怀疑是你接收这个参数的过程所用的变量不能接受这么大的数值。

另,在参考了第一篇文章之后,
得到出现的原因是
dbms_output.put_line(),这个输出过程的参数类型是varchar2,不管你用什么变量来传入,都会转成varchar2,因此会报错。

我之前使用clob直接用字符串拼接不报错是因为刚好此字符串长度不大,而此次的长度通过dbms_lob.getlength()得到的结果是4W+。

另外,
建议
lob类型的操作都有相应的专业函数,不能简单当作字符串来进行处理的
否则就会受到字符串长度的限制。

使用DBMS_LOB.Append来操作时,需要先将该对象初始化
在loop前,先执行 dbms_lob.createtemporary(v_cursor,true);
即可


参考地址:

ORACLE 存储过程返回结果集,拼接为字符串输出为clob

oracle clob参数类型的长度问题

 

 




posted on 2015-05-26 21:15  红无酒伤  阅读(2455)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3