Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Package body getting INVALID

KarkiJul 26 2015 — edited Jul 29 2015

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.

This post has been answered by BluShadow on Jul 29 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2015
Added on Jul 26 2015
8 comments
5,432 views