码迷,mamicode.com
首页 > 其他好文 > 详细

使用CLOB抛出数字或值错误异常

时间:2015-05-26 23:07:02      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

 

今天在调试某个问题的时候,由于使用了很多循环,我需要都打印出来,试图使用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参数类型的长度问题

 

 




使用CLOB抛出数字或值错误异常

标签:

原文地址:http://www.cnblogs.com/huanghongbo/p/4531792.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!