Question

I am trying to run a program in the Oracle express edition editor. When I execute the program, I get an error

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

Can anyone help me understand why I am getting an error and how to fix the code?

VARIABLE gvn_total_salary NUMBER;
DECLARE
   vn_base_salary NUMBER := 3000;
   vn_bonus NUMBER := 1000;
BEGIN
   :gvn_total_salary := vn_base_salary + vn_bonus;
END;

The output I'm getting

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


Run By SYSTEM 
Parsing Schema SYSTEM 
Script Started Thursday, April 26, 2012 
 3 seconds ago 
Elapsed time 0.01 seconds 
Statements Processed 1 
Successful 0 
With Errors 1 
Was it helpful?

Solution

What are you actually trying to accomplish? This script won't execute in sqlplus or Oracle Developer or any PL/SQL execution environment I can think of. In fact, I don't understand how you are passing the bind variable :gvn_total_salary and how you can get the error you are describing. You should get something like "bind variable gvn_total_salary" not declared.

OTHER TIPS

With the declaration of the bind variable, that code works fine for me in SQL*Plus

SQL> VARIABLE gvn_total_salary NUMBER;
SQL> DECLARE
  2     vn_base_salary NUMBER := 3000;
  3     vn_bonus NUMBER := 1000;
  4  BEGIN
  5     :gvn_total_salary := vn_base_salary + vn_bonus;
  6  END;
  7  /

PL/SQL procedure successfully completed.

SQL> print gvn_total_salary

GVN_TOTAL_SALARY
----------------
            4000

Can you connect to the database using SQL*Plus and run the same thing?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top