Number(?), what does it enforce

I am absolutely shocked and amazed that the following does not throw up an error when compiled. You only find out whats wrong when you try and run the package. Why is it that the compiler is not flagging an error? What an earth does the compiler do besides checking for syntactic errors???
create or replace package deleteme
is
g_age number(2) := 399999;
function get_it return number;
end deleteme;
Package created.
create or replace package body deleteme
is
function get_it
return number
is
     l_myage number(3) := 9999999999;
begin
     return 39;
end;
end deleteme;
Package created.
declare
x number(3);
begin
x := deleteme.get_it;
dbms_output.put_line(x);
end;
declare
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: number precision too large
ORA-06512: at "GEN.DELETEME", line 3
ORA-06512: at line 4
Gus

What an earth does the compiler do besides checking for syntactic errors??? see http://en.wikipedia.org/wiki/Compiler
ummmm...
OK, firstly, would you want your compiler to execute the code everytime you compiled?
Secondly, why would you write this code? I mean, you had to have known that it was bad when you wrote it (your declaration and assignment are in the same line).
Thirdly, is there a real questions here? If you need help with the code I have provided it below:
create or replace package deleteme
is
g_age number(2) := 1;
function get_it return number;
end deleteme;
create or replace package body deleteme
is
function get_it
return number
is
l_myage number(3) := 0;
begin
return 39;
end;
end deleteme;

Similar Messages

Maybe you are looking for