ORA-06502:PL / SQL:数字或值错误:字符串缓冲区太小 [英] ORA-06502: PL/SQL: numeric or value error: character string buffer too small

查看:7257
本文介绍了ORA-06502:PL / SQL:数字或值错误:字符串缓冲区太小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下代码的不同方式,比如取出while或if,但是当我把两者放在一起时(if和while),我总是得到错误...

I tried the following code different ways, like by taking out the while or the if, but when I put both together (if and while), I always get the error at the end...

undefine numero
set serveroutput on
accept numero prompt 'Type # between 100 and 999: '
declare
   i number:=1;
   a char(25);
   b char(1);
   c varchar2(10);
   d number;
begin
   c := №
   d := length(c);
   b := substr(c, i, 1);
   while i <= d loop
     if b = '1' then
       a:= a||'one ';
     end if;
     i := i+1;
   end loop;
   dbms_output.put_line('The number is '||a);
end;
/

错误:

ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 13
06502. 00000 -  "PL/SQL: numeric or value error%s"

通过更改我声明变量的方式进行修复 ato:

a varchar2(2000);


推荐答案


PL / SQL:数字或值错误:字符串缓冲区太小

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

是由于您将字符串声明为固定长度(比如说20),在你的代码中的某个时刻,你给它分配一个长度超过你声明的值的值。

is due to the fact that you declare a string to be of a fixed length (say 20), and at some point in your code you assign it a value whose length exceeds what you declared.

例如:

myString VARCHAR2(20);
myString :='abcdefghijklmnopqrstuvwxyz'; --length 26

将触发此类错误

这篇关于ORA-06502:PL / SQL:数字或值错误:字符串缓冲区太小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆