Hi Friends,
Could you help me understanding this behaviour of oracle.
SQL> create or replace package mypkg is
2 v_statevar number := 40;
3 procedure myproc;
4 end mypkg;
5 /
Package created.
SQL> create or replace package body mypkg is
2 procedure myproc is
3 myval number;
4 begin
5 select x
6 into myval
7 from dependonme;
8
9 -- myval := myval * mypkg.v_statevar;
10 DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
11 end;
12 end mypkg;
13 /
Package body created.
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG';
OBJECT_NAME OBJECT_TYPE STATUS
------------------------------ ------------------- -------
MYPKG PACKAGE VALID
MYPKG PACKAGE BODY VALID
SQL> set serveroutput on
SQL> exec mypkg.myproc;
My Result is: 5
PL/SQL procedure successfully completed.
SQL> create or replace package mypkg is
2 v_statevar number := 150;
3 procedure myproc;
4 end mypkg;
5 /
Package created.
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG';
OBJECT_NAME OBJECT_TYPE STATUS
------------------------------ ------------------- -------
MYPKG PACKAGE VALID
MYPKG PACKAGE BODY INVALID
SQL> set serveroutput on
SQL> exec mypkg.myproc;
My Result is: 5
PL/SQL procedure successfully completed.
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG';
OBJECT_NAME OBJECT_TYPE STATUS
------------------------------ ------------------- -------
MYPKG PACKAGE VALID
MYPKG PACKAGE BODY VALID
SQL>
How come changing the value of variable in package specification makes the package body invalid.
How execution of procedure of package makes the state VALID again.