ORA-06502 at runtime?

From: steph <stephan0h_at_yahoo.de>
Date: Wed, 13 Feb 2008 06:57:50 -0800 (PST)
Message-ID: <b4d2e879-3c21-4b54-b96f-2d4c951afd50@h11g2000prf.googlegroups.com>


Here is an example I would like to habe an opinion about (version is 9.2.0.6.0):

create or replace package pkg_test as

  function ret_str return varchar;

end;
/

create or replace package body pkg_test as   c_str varchar2(5):='0123456789';

  function ret_str return varchar is
  begin
    return c_str;
  end;

end;
/

Obviously 'c_str' is defined too small for the string assigned. But still, the package compiles just fine.

But when I call the function I get an error:

SQL> select pkg_test.ret_str from dual;
select pkg_test.ret_str from dual

       *
FEHLER in Zeile 1:
ORA-06502: PL/SQL: numerischer oder Wertefehler: Zeichenfolgenpuffer zu klein
ORA-06512: in "PFMS.PKG_TEST", Zeile 2

So why is the package compiling without error? Why is the error appearing at runtime?

thanks,
stephan Received on Wed Feb 13 2008 - 08:57:50 CST

Original text of this message