Home » SQL & PL/SQL » SQL & PL/SQL » ora-06502 when printing long varchar
ora-06502 when printing long varchar [message #7958] Fri, 18 July 2003 12:23 Go to next message
soy
Messages: 6
Registered: July 2003
Junior Member
In my declare section I have a variable that is:
varx varchar2(2000) := 'a really long string';
The string is actually around 1800 characters long
Inside the begin block I do:
dbms_output.enable(10000);
dbms_output.put_line(varx);

When I run the plsql code I get:
ORA-06502: PL/SQL: numeric or value error

PL/SQL procedure successfully completed.

If I take the put_line out then all is well and no error. What is going on? How do I fix this?
Re: ora-06502 when printing long varchar [message #7961 is a reply to message #7958] Fri, 18 July 2003 12:57 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Soy,

The DBMS_OUTPUT.PUT_LINE procedure has an unfortunate upper limit of 255 characters:
SQL> DECLARE
  2      l_ok_string         VARCHAR2(1000) := RPAD('X',25<b><font color=blue>5</font></b>,'X');
  3      l_bad_string        VARCHAR2(1000) := RPAD('X',25<b><font color=red>6</font></b>,'X');
  4  BEGIN
  5      DBMS_OUTPUT.PUT_LINE('1');
  6      DBMS_OUTPUT.PUT_LINE(l_ok_string);
  7      DBMS_OUTPUT.PUT_LINE('2');
  8      DBMS_OUTPUT.PUT_LINE(l_bad_string);
  9      DBMS_OUTPUT.PUT_LINE('3');
 10  END;
 11  /
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX....
2
DECLARE
*
ERROR at line 1:
ORA-20000: ORU-10028: line length overflow, limit of 255 bytes per line
ORA-06512: at "SYS.DBMS_OUTPUT", line 84
ORA-06512: at "SYS.DBMS_OUTPUT", line 58
ORA-06512: at line 8
  
  
SQL> 
See this link for some potential workarounds.

But you're getting a different error: Are you sure you're not putting more than 2000 characters into your varx variable?
SQL> DECLARE
  2      x   VARCHAR2(5);
  3  BEGIN
  4      x := '123456';
  5  END;
  6  /
DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 4
  
  
SQL> 
Good luck,

Art
Re: ora-06502 when printing long varchar [message #7962 is a reply to message #7961] Fri, 18 July 2003 14:01 Go to previous messageGo to next message
soy
Messages: 6
Registered: July 2003
Junior Member
I'm getting a slightly different error now but I think it is the same problem.
ERROR at line 1:
ORA-20000: ORU-10028: line length overflow, limit of 255 bytes per line
ORA-06512: at "SYS.DBMS_OUTPUT", line 99
ORA-06512: at "SYS.DBMS_OUTPUT", line 65
ORA-06512: at line 78

here's my code:
http://www.havennet.net/temp/failrun.txt

So doing what was in the previous link you posted should get around the 255 limit (using the my_dbms package)?
Re: ora-06502 when printing long varchar [message #7966 is a reply to message #7962] Fri, 18 July 2003 15:36 Go to previous messageGo to next message
soy
Messages: 6
Registered: July 2003
Junior Member
I tried using the my_dbms_output package but the body package wouldn't compile without errors. So I'm not sure what I'm gonna do.
Re: ora-06502 when printing long varchar [message #7972 is a reply to message #7966] Fri, 18 July 2003 19:05 Go to previous message
soy
Messages: 6
Registered: July 2003
Junior Member
Well i fixed the problem, it was dumb. I didn't execute the original statement. Duh, it is always the simple things. :)
Previous Topic: howto activate archive log on W2K?
Next Topic: quest
Goto Forum:
  


Current Time: Fri Apr 26 11:31:16 CDT 2024