31 March 2008

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

Make sure that the size of the target variable is same as the size of the assign value.

Examples:

-- Correct Way.
fstrVar1 VarChar2 (5);
fstrVar2 VarChar2 (5);

fstrVar2 := ‘12345’;
fstrVar1 := fstrVar2;

-- Incorrect Way.
fstrVar1 VarChar2 (4);
fstrVar2 VarChar2 (5);

fstrVar2 := ‘123456’; -- Error prompted here because fstrVar2 only accept 5 characters.

-- If fstrVar2 is changed to accept 6 characters.
fstrVar1 := fstrVar2; -- Error prompted here because fstrVar1 only accept 4 characters.

No comments: