ORA-06502: PL/SQL: numeric or value error: character string buffer too small

执行存储过程中报如下错误:ORA-06502: PL/SQL: numeric or value error: character string buffer too small

经过排查,发现是由于赋予变量的值超过了变量定义的长度。

定义的字符变量长度为3位:

v_operator_1  varchar2(3);

实际上赋予变量的值threshold_operator中有多余的两位空格字符,导致实际字符大于了3位:

select threshold_operator, threshold_value into v_operator_1, f_threshold_1 from t_conf_threshold where kpi_id = 101001000100;

解决方法是修改变量定义的长度,或者剔除字段中的空值,如下:

select rtrim(ltrim(threshold_operator)), threshold_value into v_operator_1, f_threshold_1 from t_conf_threshold where kpi_id = 101001000100;

综上,我们在定义变量的时候一定要注意其长度是否满足需要,或者在取值的时候尽量要剔除空格字符。

 

----END;



posted @ 2012-01-04 14:23  Mr.chenz  阅读(25559)  评论(1编辑  收藏  举报